Purpose of setting the environment variable XX_HOME

Source: Internet
Author: User

Purpose of setting the environment variable XX_HOME

When installing Hadoop tools, you need to set XX_HOME, which is sometimes confusing. Because I use the brew package installer on Mac OS x to install these tools, and then I can run commands on the terminal without setting XX_HOME.

Java-related environment variables are set:

1. Set JAVA_HOME:
1. For reference convenience, for example, if your JDK is installed in the C: \ Program Files \ Java \ jdk1.6.0 directory, set JAVA_HOME to the directory path, to use this path in the future, you only need to enter % JAVA_HOME % to avoid entering a long path string for each reference;
Ii. Normalization principle: when your JDK path is forced to change, you only need to change the variable value of JAVA_HOME. Otherwise, you need to change any document that uses the absolute path to reference the JDK directory, if you fail to complete the changes and a program cannot find the JDK, the consequence is that the system crashes!
3. The third-party software will reference the agreed JAVA_HOME variable. Otherwise, you will not be able to use the software normally. After using JAVA for a long time, you will know that if a software cannot be used normally, think about the problem.

2. Set CLASSPATH:
This is a very interesting question. Of course, it is also a question that affects beginners. The purpose of this variable setting is to allow the program to find the corresponding ". for example, compile a java program ---. java,. class file. If you execute java A in the current directory, the corresponding result will be obtained (provided that you have set CLASSPATH ". "). now. when the class is moved to another directory (for example, "e: \") and java A is executed, there will be A NoClassDefFindError exception because it cannot be found. class file, now you add CLASSPATH :".; e: \ "run java A again to see what the result will be ~~ :)~~~, Everything is normal. The java Command finds the. class file through CLASSPATH!

3. Set PATH:
The principle is very simple. Do you want to use % JAVA_HOME % \ bin \ java to execute java commands at any time? Of course not, so, you can add % JAVA_HOME % \ bin to the PATH. In this way, we can use java to execute commands in any PATH. (When you enter your code in the Command Prompt window, the operating system will find the corresponding application in the current directory and PATH variable directory and execute it .)

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.