• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception in thread "main" NoClassDefFoundError

 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I tried to compile and run the following java code.

It is compiling well and the class file is created.but when running the code it shows the following error:

Exception in thread "main" java.lang.NoClassDefFoundError: Script Caused by: java.lang.ClassNotFoundException: Script at java.net.URLClassLoader$1.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClassInternal(Unknown Source)


please tell me where am i wrong.Thanks
 
Sudarshan Chakrabarty
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The exception is due to this line


Your factory class is unable to find(and load) the class referred by "JavaScript".
 
Campbell Ritchie
Sheriff
Posts: 48381
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apart from the spelling error (please use ctrl-c ctrl-v when posting such code), you need to check that the class file is actually in the folder your command line is "pointing to" at present. Make sure your classpath contains .; or ;. or ;.; (on Windows at least) and make sure your folder contains the .class file, using dir on Windows or ls on *nix. Make sure you haven't got any more spelling errors, like script for Script.
 
Campbell Ritchie
Sheriff
Posts: 48381
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I copied and pasted that code and tried it myself and it ran first time once I got rid of the obvious spelling error. I suspect there is another spelling error you have obscured by writing the code by hand. Please see the link I quoted.
 
preethi Ayyappan
Ranch Hand
Posts: 518
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks.the classpath is the actual problem.After setting it correctly,it is working
 
Campbell Ritchie
Sheriff
Posts: 48381
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome ( ). What have you set your classpath to now?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic