aspose file tools*
The moose likes Beginning Java and the fly likes Exception in thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception in thread "main" NoClassDefFoundError" Watch "Exception in thread "main" NoClassDefFoundError" New topic
Author

Exception in thread "main" NoClassDefFoundError

preethi Ayyappan
Ranch Hand

Joined: Oct 04, 2007
Posts: 518
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

Joined: Apr 10, 2008
Posts: 38
The exception is due to this line


Your factory class is unable to find(and load) the class referred by "JavaScript".
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39885
    
  28
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

Joined: Oct 13, 2005
Posts: 39885
    
  28
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

Joined: Oct 04, 2007
Posts: 518
thanks.the classpath is the actual problem.After setting it correctly,it is working
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39885
    
  28
You're welcome ( ). What have you set your classpath to now?
 
wood burning stoves
 
subject: Exception in thread "main" NoClassDefFoundError