When installing the Hadoop series tools, it's hard to set xx_home, sometimes confusing. Because I installed these tools with the Brew Suite installer on Mac OS X, and then I didn't set up xx_home to run the command at the terminal.
The Java-related environment variable settings are designed to:
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.)
Purpose of setting Xx_home environment variables