The role of environment variables in the setting of the Java environment variables

Source: Internet
Author: User

Path : (case-insensitive)

The system variable path tells the operating system executable (*.exe, *.bat, and so on) the path where the OS (OS) discovers a *.exe when theWindows By default, starting from the current directory to find this command, if not found, the OS will go to path set to find the command, and then execute . The system default system variables are:

Path =%systemroot%;%systemroot%/system32;%systemroot%/system32/wbem

That is, in the above 3 directories (multiple variables separated by semicolons) in the *.exe file, can be executed anywhere (commands that can be executed directly in the Run window, such as CMD, Notepad, etc., basically in the above 3 directories), so they can run directly.

path=*********;%java_home%\bin;%java_home%\jre\bin;********

(* represents the original configuration%java_home%\jre\bin can be omitted)

For example, compiling and running a Java file requires two steps (1) to compile the source file into bytecode (2) to interpret the execution platform-independent bytecode program. The above two steps require the use of both Java and Javac commands respectively. Assuming that you open the command line to execute Java and Java on the premise of installing the JDK, you will be prompted not to internal or external commands. This is because: although we have installed the JDK on the computer, and the JDK installation path also contains Java and javac two commands, but the computer does not know where to find the two commands.
The Windows operating system looks for commands based on the PATH environment variable. The value of the PATH environment variable is a series of paths that the Windows operating system will look for at a time in this series of paths, which can be executed if the command is found. If it cannot be found, an error is reported that is not an internal or external command.

Classpath : (case-insensitive)

Classpath is specifically for Java, andClasspath tells the Java Virtual Machine (JVM) where to put the *.class files to be used or executed, when we need to refer to a class that someone else has written when developing a Java program. Let the Java interpreter know where to look for this class. sometimes the default (current path) is enough for us, so it is sometimes possible not to set classpath. In general, Sun provides us with some extra rich class packages, one is Dt.jar, the other is Tools.jar, and these two jar packages are located in the C:\jdk1.6.0\lib directory, so we usually add these two jar packages to our CLASSPATH environment variable. Note Add the current directory.

Classpath=.; %java_home%\lib\tools.jar;%java_home%\lib\dt.jar;%java_home%\lib

Java_home : (case-insensitive)

one is to facilitate the reference , for example, the JDK installed in the C:\Program Files (x86) \java\jdk1.6.0_30 directory, then set Java_home as the directory path, then to use this path later, just enter the% Java_home%, avoid entering a long path string for each reference;

The second is a principle , when the JDK path changes, only need to change the value of the java_home variable, otherwise, it is necessary to change any of the absolute path reference JDK directory document, if there is no change, a program can not find the JDK, the consequences can be imagined-the system crashes!

Thirdly, third-party software will refer to the agreed-upon java_home variable , otherwise you cannot use the software normally.

Java_home=c:\program Files (x86) \java\jdk1.6.0_30

Setup method: Right click on My Computer, select "Properties", select "Advanced" tab, enter environment variable settings, set three environment variables respectively. The path variable already exists and needs to be edited, Java_home and Classpath to create their own.

The role of environment variables in the setting of the Java 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.