Configuration of Java Environment variables

Source: Internet
Author: User

***************************************

Why to configure environment variables: 1. The PATH environment variable (window is case-insensitive and must be capitalized under the Linux system).

The function is to specify the command search path

When executing a command in CMD, it looks in the path specified by the path variable to see if the appropriate command program can be found. We need to add the bin directory in the JDK installation directory to the existing path variable, the bin directory contains frequently used executables such as Javac Java Javadoc Wait, set the path variable, you can execute Javac Java and other tools in any directory.

Like the PATH environment variable inside a%systemroot%\system32 refers to the system root directory in the system32 directory (C:\WINDOWS\SYSTEM32), if you do not set it, then you directly cmd under > Notepad is not to be summoned out of Notepad.

test: If the direct input Java Javac No, is the path setting problem

2. CLASSPATH environment variables.

(version 1.8 does not need to be set, it is said to automatically add local path, but because some companies will use the JDK is not the latest version, set up or relatively stable)

The function is to specify the class search path

To use classes that have already been written, the premise is to be able to find them, but the JVM is looking for classes through classpath. We need to set the Dt.jar and Tools.jar in the Lib subdirectory of the JDK installation directory to classpath, of course, the current directory "." must also be added to the variable. (Current directory: the Java code compiled by the class file exists in the current directory, the runtime class file must be in the classpath corresponding directory.) )

test: Javac xxx (does not require. Class), if you do not set the current directory, even if you jump to the current directory in CMD can not javac to the target file

3. Java_home environment variables.

It points to the JDK's installation directory, and software such as Eclipse/netbeans/tomcat finds and uses the installed JDK by searching for java_home variables.

In addition, other environment variable settings can be%java_home% to obtain the value of the JAVA_HOME environment variable to facilitate setup

Ps:

the difference between a user variable and a system variable:

The difference between the variables used by the current user and the common variables of the system's individual users.

Variable settings: ************classpath variable ***************

Open My Computer--Properties--advanced--environment variables

***************************************

2.

New variable

Java_home

where the variable name is the installation JDK the path;

***************************************

3. Create a new variable

Classpath/classpath (two variable names available)

Variable value:.; %java_home%\lib\dt.jar;%java_home%\lib\tools.jar;

Mean:

· %java_home%-----Get java_home Variable value, then%java_home%\lib\dt.jar;%java_home%\lib\tools.jar; means Lib\dt.jar and \lib\ under the JDK installation path Tools.jar

· Lib\dt.jar and \lib\tools.jar

Dt.jar and Tools.jar are the two most basic Java packages that contain the most important lang packets from Java to various advanced functions such as the visual Swing package, which is essential for Java.

Tools.jar is used when the system compiles a class, that is, when the javac is executed.

· Rt.jar is the Java base Class library (default in the load path, default does not need to add), Dt.jar is about the runtime environment of the class library (mainly swing), Tools.jar is the tool class library

Path variable ******************

And the bin below the path is Java executable compiler and its tools, such as Java,javadoc, you run cmd under any folder type Javac, the system can automatically summon Java compiler is attributed to this environment variable setting

Select " Environment Variables " the variable name is "Path" environment variable, double-click the variable to JDK in the installation path bin absolute path to the directory (full write path) , added to Path the value of the variable.

Or is:

%java_home%\bin;%java_home%\jre\bin;

Plus JRE is used for non-compiler run programs

!!! Do not delete the wrong things, delete just press Cancel, and then again.

PATH environment variable set successful test: Run cmd, enter java–version

Configuration of Java Environment variables

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.