today again set up the Java environment variables, suddenly found every time the settings are just follow the steps to set it up, do not know why to set up, so the internet looked for, find the article, feel good, left.
For record learning only. Transferred from: http://bbs.tech.163.com/bbs/tech_0ik1/147645925.html
After installing the JDK on the computer, let's make the settings available to the Java environment. First right click on my Computer. Open the property. Then select "Environment Variables" in "Advanced", the system variables in the new open interface need to set three properties "Java_home", "path", "Classpath", where the JDK is not installed in the environment. The path attribute is already present. and Java_home and classpath do not exist.
One: Point "new", and then in the variable name write on Java_home, gu name the meaning of the variable is the Java installation path, hehe, and then in the variable value to write the path just installed "C:\jdk1.6". (Note: If the path installed is not disk C or is not in the jdk1.6 folder, it can be modified.) The following text is assumed to be installed inside the C:\jdk1.6. )
Second: In the system variable to find the path, and then click Edit, the meaning of the path variable is that the system can be any path to identify the Java command, the value of the variable is ".; %java_home%\bin ", (where"%java_home% "means to set the value of the java_home just now), you can also write" C:\jdk1.6\bin "directly
Three: Finally click "New", then write classpath on the variable name, the meaning of the variable is the Java load Class (or LIB) path, only the class in Classpath, the Java command can be recognized. Its value is ".; %java_home%\lib\dt.jar;%java_home%\lib\toos.jar (to Add. Indicates the current path) ", same as"%java_home% "
When the above three variables are set, press OK until the Properties window disappears, and it is verified to see if the installation was successful. First open "Start", "Run", enter "cmd", into the DOS system interface. Then hit "Java-version" if the installation was successful. The system displays the Java version jdk "1.6.0".
Ensure that the C-drive file name is jdk1.6, the environment variable is copied directly, enter JAVAC in the DOS interface to see if the command is legitimate, and also enter Java to see if the command is legitimate
So the environment variable is set up, the following to explain the Path,classpth,java_home
The following are the purposes of Java_home,classpath,path:
1, set Java_home:
First, for the convenience of reference, for example, your JDK installed in the C:\Program files\java\jdk1.6.0 directory, then set Java_home as the directory path, then you want to use this path later, just enter%java_home%, Avoid entering a long path string for each reference;
Second, the principle, when you are forced to change the JDK path, you only need to change the value of the java_home variable, otherwise, you will change any of the absolute path references to the JDK directory of the document, if you do not change the whole, a program can not find the JDK, the consequences are imagined----system crashes!
Third-party software will refer to the agreed java_home variable, otherwise, you will not be able to use the software, after a long time in Java will know that if a software does not work properly, you may want to think about this is not the problem.
2, set Classpath:
This is a very interesting, of course, the problem of torture beginners, the purpose of this variable setting is to find the corresponding ". Class" file, you can give an example: you compile a Java program---a.java, you will get a A.class class file, You execute Java A in the current directory, you will get the result (if you have set Classpath to "."). Now, you move the a.class to a different directory (for example: "E:\"), execute Java A, there will be Noclassdeffinderror exception, because the. class file is not found, now you add Classpath to: ".; E:\ "Run Java A again to see what results ~ ~ ~:) ~ ~ ~, everything is OK, java command found the. class file through Classpath!
3, set path:
The reason is simple, you want to use%java_home%\bin\java and so on at any time to execute JAVA commands, of course, you can choose to add%java_home%\bin to path path, so, We can use Java to execute commands under any path. (When you enter your code in the Command Prompt window, the operating system looks for the appropriate application in the current directory and path variable directory, and executes.)
The setting and function of the java_home path classpath in the Java Bad environment variable. --------Reprint