Directory:
- Java installation (cannot find or Load main class Com.sun.tools.javac.Main)
- Setting environment variables
1. Java Installation
Scenario: Do not use the default installation
Problem: Cmd-javac cannot find or load the main class Com.sun.tools.javac.Main
Workaround: Uninstall, reinstall, JDK and JRE cannot be installed in a folder.
e.g. JDK--D:\program\Java\jdk1.7.0_79
JRE--D:\program\Java\jre7
Cause: During the installation of the JDK, a JRE installation will also pop up, and the JDK cannot be installed in the same directory, otherwise it will conflict, causing Javac.exe to be deleted. (Click here to view the original) if you use Java's default installation, a closer look will find that the default installation path for the JDK and the JRE that pops up later is really different.
2. Setting Environment variables
- Java_home--D:\program\Java\jdk1.7.0_79 (JDK installation path)
- Path--%java_home%\bin;%java_home%\jre\bin;
- CLASSPATH--.; %java_home%\lib\dt.jar;%java_home%\lib\tools.jar;
- Test environment variable is configured successfully
cmd > Java-version
> javac-version
- The meaning of a variable
-->path:
Java variables: Provides parameters for systems and applications.
Environment variable Path: tells the system and application where to store some of the prerequisite programs.
Using the ipconfig command in CMD, essentially Ipconfig is an executable program (similar to >java xxx, >javac xxx), and how does the system know the location of the program? environment variable PATH. If it is not found, it returns "' ipconfig ' is not an internal or external command, nor is it a running program or batch file. ”
-->classpath: Although the system now finds Java and javac through path, there are still some things that can't be found, what is it? The class library file for Java. such as importing or hiding the imported tear file through import java.xx.xx display. In addition, the location of the program you write is also best put in.
-->java_home: Well, it's for Jingxiang.
When you set the path, you want to enter:
C:\Program files\sun\java\jdk1.6.0_02\ Bin
Or prefer to enter:
%java_home%\ Bin
And if the installation path changes, you only need to modify the Java_home, not the path, Classpath also need to be modified together. -
Here's a more nagging explanation (click here).
Java installation and setting environment variables