| Author |
No ClassDefFoundError
|
JayaSiji Gopal
Ranch Hand
Joined: Sep 27, 2004
Posts: 303
|
|
hi, i have a program in IO with a main method. I am trying to run the program thru the console. however, it gives me java.lang.NoClassDefFoundError. I have configured java home, the bin and the lib folders. also added the working folder to the classpath. i also tried to go into the directory containing the .class file and run the same with the java command. However, i get the same error. wht am i missing?
|
SCJP 1.4, SCWCD 1.4<br /> <br />Thanks in advance!<br />Jayashree.
|
 |
somkiat puisungnoen
Ranch Hand
Joined: Jul 04, 2003
Posts: 1312
|
|
public class NoClassDefFoundError extends LinkageError Thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found. The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found.
|
SCJA,SCJP,SCWCD,SCBCD,SCEA I
Java Developer, Thailand
|
 |
Nigel Browne
Ranch Hand
Joined: May 15, 2001
Posts: 673
|
|
|
If you post the error message you receive we might be able to help, but there is definately something wrong in the way you are trying to access a class.
|
 |
Vedhas Pitkar
Ranch Hand
Joined: Jan 27, 2001
Posts: 445
|
|
|
Is the class public?
|
 |
JayaSiji Gopal
Ranch Hand
Joined: Sep 27, 2004
Posts: 303
|
|
Originally posted by somkiat puisungnoen: [QB][/QB]
This is the text of the error message that i receive : C:\Jayashree\Examples\printHTML\classes\test\print>java printHTML Exception in thread "main" java.lang.NoClassDefFoundError: printHTML (wrong name : test/print/printHTML) at java.lang.ClassLoader.defineClass0(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.defineClass(Unknown Source) at java.net.URLClassLoader.access$100(Unknown Source) 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)
|
 |
Pitchaimani Raju
Greenhorn
Joined: Sep 08, 2004
Posts: 1
|
|
hi Gopal , i think so, your class printHTML is under package test.print. you have to run your class from C:\Jayashree\Examples\printHTML\classes folder and you have to give the following command java test.print.printHTML. now it will work properly. Regards, Loga
|
Regards<br />Pitchaimani Raju
|
 |
somkiat puisungnoen
Ranch Hand
Joined: Jul 04, 2003
Posts: 1312
|
|
|
Please post your code to solve this problem.
|
 |
somkiat puisungnoen
Ranch Hand
Joined: Jul 04, 2003
Posts: 1312
|
|
Originally posted by Vedhas Pitkar: Is the class public?
I think, public Class name in source code is not "printHTML".
|
 |
Ashish Vegaraju
Ranch Hand
Joined: Aug 19, 2004
Posts: 47
|
|
hi, this error generally comes if ur classpath is not set correctly...do the following.. open command prompt and write this command set CLASSPATH=%CLASSPATH%C:\j2sdk1.bla...bla...version\bin;.(semicolon followed by full stop[THIS IS IMP]) try this...if it doesnt help..let me know Ashish.
|
 |
 |
|
|
subject: No ClassDefFoundError
|
|
|