Purpose of setting Xx_home environment variables

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.