Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in thread "main"

 
rick collette
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have the following class, it compiles, but gives me
the following error:
Exception in thread "main" java.lang.NoClassDefFoundError:
---------
public class ServiceClient{
public static void main(String args[]){
System.out.println("Hi!");
}
}
I am wondering if something is wrong with my classpath:
CLASSPATH: C:\jdk1.3.1\bin;C:\j2sdkee1.3.1\bin
JAVA_HOME: C:\jdk1.3.1

I recently installed win2k, it never happened on my win98. I got the same problem on Eclipse with different "program will exit" error.
Thanks,
Rick
 
Philip Shanks
Ranch Hand
Posts: 189
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't see '.' in the class path. It appears that the runtime class loader is finding everything except the class that you wrote! If you are going to specify a class path, then you need to have the current directory as part of it.
Execution from the command line (assuming you are in the same directory as MyClass.class) would look something like this:
java -cp .;path\to\jsee.jar;path\to\another.jar MyClass optional cmd line args
 
rick collette
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Philip:
Yes, you are right. I actually put '.' on my classthpath. And even I rebuid the program, it still throws me the same error. Rather strange.
thanks,

Originally posted by Philip Shanks:
I didn't see '.' in the class path. It appears that the runtime class loader is finding everything except the class that you wrote! If you are going to specify a class path, then you need to have the current directory as part of it.
Execution from the command line (assuming you are in the same directory as MyClass.class) would look something like this:
java -cp .;path\to\jsee.jar;path\to\another.jar MyClass optional cmd line args
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic