Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NoClassDefinationFoundError

 
D vaibhav deshmukh
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class WTest
{
static Integer y;
static int x;
public static void main(String[] args)
{
y = new Integer(143);
x = y.intValue();
x++;
y = new Integer(x);
System.out.println("Y = " +y);
}
}


I am able to compile the above programm fine. But, when I tried to run it is throwing a statement saying:

"Execption in thread "main" java.lang.NoClassDefinationFoundError : WTest"

Why???

Please reply.....
 
Red Smith
Ranch Hand
Posts: 136
1
Netscape Opera Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by D vaibhav deshmukh:




I am able to compile the above program fine. But, when I tried to run it is throwing a statement saying:

"Execption in thread "main" java.lang.NoClassDefinationFoundError : WTest"

Why???

Please reply.....


That code worked for me (prints 144) without error. Are you typing "java WTest" or "java wtest"? What you type after java has to match the case of the class in the file (and the filename) exactly.
[ August 11, 2007: Message edited by: Red Smith ]
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like the command is using the correct case, because the exception message says "WTest" (assuming this is the exact message).

So my bet is that there is a system classpath set that does not include a dot (.) for the current directory. Try running with:

java -classpath . WTest

If this works, then you should consider removing the system classpath. Or if it contains something you really need, then add a dot for the current directory.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic