Compiler Error - 'Error: Could not find or load main class com.sun.tools.javac.Main'

前端 未结 7 2082
眼角桃花
眼角桃花 2020-12-16 16:03

I just started learning Java and I installed JDK on my computer, but now I am trying the SIMPLIST of Java and its not compiling. I installed JDK on C:/Java/jdk7/

7条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-16 16:48

    You probably have done a manual installation of JDK. Anyway, this error is almost certainly due to a flaw in your Java installation. In order to solve it, you must execute the following command in your JAVA_HOME/lib directory:

    unpack200 -r -v -l "" tools.pack tools.jar

    This will unpack the tools.jar file, which your installation (manual or not) had not done for you. After that try to execute:

    javac -version

    This command should work well. This is similar to the error you can have with the Java command, for basically the same reason, your installation didn't unpack necessary files. You can refer to this link: JRE 1.7 returns: java/lang/NoClassDefFoundError: java/lang/Object

    I had this problem myself and my solution is a little adaptation of this other answer.

提交回复
热议问题