Sunday, August 2, 2009

What is this error in Java?

C:\dynamicDeployment\build%26gt;java com.dynamic.deployment.DynDeploymentMain a a


Exception in thread "main" java.lang.NoClassDefFoundError: com/dynamic/deploymen


t/DynDeploymentMain


Caused by: java.lang.ClassNotFoundException: com.dynamic.deployment.DynDeploymen


tMain


at java.net.URLClassLoader$1.run(Unknown Source)


at java.security.AccessController.doPrivile... Method)


at java.net.URLClassLoader.findClass(Unknow... Source)


at java.lang.ClassLoader.loadClass(Unknown Source)


at sun.misc.Launcher$AppClassLoader.loadCla... Source)


at java.lang.ClassLoader.loadClass(Unknown Source)


at java.lang.ClassLoader.loadClassInternal(... Source)





C:\dynamicDeployment\build%26gt;

What is this error in Java?
You need to add the jar file to your class path:


set CLASSPATH=C:\path\to\my.jar
Reply:This can be several things. But if you are just starting out ... a newbie does this





%26gt; javac MySpiffyClass.java


%26gt; java MySpiffyClass.class





The first line is correct. The 2nd line should be.


java MySpiffyClass





If that's not it. It can be your MySpiffyClass.class is not in C:\dynamicDeployment\build





If it's not those two things. Then we have mal-formed code. If we don't suspect the code, we can suspect we don't have the environment path variable set correctly for the JRE library.
Reply:it means it couldn't find the class or jar. u might have to check ur class path. find the location of that jar and add that to ur class path. then try to compile or execute it.
Reply:NoClassDefFoundError can represent two things - class not available in classpath AND even if class is there there is version mismatch in file seeked and file available.


In your case it is that DynDepl.. class is not found in class path since exception is raised from ClassNotFoundException


No comments:

Post a Comment