• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NoClassDefinationFoundError

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.....
 
Ranch Hand
Posts: 136
1
Netscape Opera Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Good night. Drive safely. Here's a tiny ad for the road:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic