开发者

javac (and other jdk executables) produce NoClassDefFoundError

On Solaris 10, I'm using JDK 1.5.0_22 and when I run any of the JDK executables (javac, native2ascii, javadoc, etc) in the JDK/bin directory that require tools.jar to run, I get this error (run with and without arguments):

Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/javac/Main

JRE executables in the bin directory which do not require tools.jar work fine (java, keytool, etc).

Yes, tools.jar is located in the JDK/lib directory, and the permissions are OK and it's not corrupt - I am able to view contents of tools.开发者_如何学编程jar and extract them.

I have tried setting JAVA_HOME, and adding the JDK/bin directory to PATH - setting/unsetting these environment variables makes no difference. I still get the same error.

This is the only thing I have found that does get rid of the NoClassDefFoundError and allow the JDK/bin executable to run (cmd below is run from the JDK/bin directory):

./native2ascii -J-Xbootclasspath/a:../lib/tools.jar

So if I add -J-Xbootclasspath/a:../lib/tools.jar to any JDK/bin executable like javac, javadoc, native2ascii, they run. Otherwise, they do not.

Any ideas on how to fix? All of the JDK/bin executables run fine on other Solaris 10 systems I have, and none of them have any JAVA_HOME vars set or JDK/bin on the PATH.


This NoClassDefFoundError is 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.

The JAVA_HOME should not be set up to the BIN folder. It should be one level up like this:JDK_HOME = C:\Program Files\Java\jdk1.6.0_18

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜