Three environment variables (JAVA_HOME, CLASSPATH, and PATH) that need to be set frequently in JAVA)

Source: Internet
Author: User

Three environment variables that need to be set frequently in JAVA:
JAVA_HOME, CLASSPATH, PATH
(1) Configure environment variables: (relative path)
1. JAVA_HOME = x:/jdk1.6.0
2. Replace: x:/jdk1.6.0 with % JAVA_HOME %.
CLASSPATH =.: $ JAVA_HOME/lib/tools. jar: $ JAVA_HOME/lib/dt. jar: $ JAVA_HOME/lib/activation. jar: $ JAVA_HOME/lib/mail. jar
Or CLASSPATH =./; % JAVA_HOME %/lib/tools. jar; % JAVA_HOME %/lib/dt. jar
3. PATH =.; % JAVA_HOME %/bin
(2) Configure environment variables: (absolute path)
1. Java_HOME = D:/jdk1.5.0
2. CLASSPATH =.; D:/jdk1.5.0/lib/tools. jar; D:/jdk1.5.0/jre/lib/rt. jar;
3. PATH = D:/jdk1.5.0/bin;


Note:
JAVA_HOME: The software depends on this variable to find the JDK installation directory. If this variable is not set, the software package can hardly find where javac.exe is. This environment variable is used to determine the path of javac.exe to execute compile tasks. The value of this environment variable is your jdk installation directory. If your jdk is installed in c:/jdk1.42, "c:/jdk1.42" is the value of JAVA_HOME.
CLASSPATH: A class path that tells the Java application where to find third-party and custom classes-that is, classes that are not part of Java extensions or Java platforms. In JDK 1.2, JVM and other JDK tools search for classes by platform libraries, library extensions, and class paths (for more information about search policies, see how to find classes ). Most application class libraries make full use of the extension mechanism. Therefore, you must set a class path only when you want to load a class library (a) that is not in the current directory or its branch package and (B) that is not in the position specified by the extension mechanism. In addition to paths, the CLASSPATH list can also contain. jar files. The. jar file is used as a directory to search for classes in Java. Generally, we need to include jre/lib/rt. jar (Linux: jre/lib/rt. jar) in the JDK installation path in CLASSPATH. The first thing to note is the front "..;". If you cannot see it clearly, I will read it for you-a semicolon. This tells JDK to first find the CLASS file in the current directory when searching for the CLASS-why? This is caused by the LINUX security mechanism. LINUX users understand it very well, WINDOWS users are hard to understand (because the default search order in WINDOWS is to search the current directory first, then the system directory, and then the PATH environment variable ), so if you like LINUX, you may want to study LINUX.
PATH: Specifies a PATH list for searching executable files. When executing an executable file, if the file cannot be found in the current PATH, find each PATH in the PATH in sequence until it is found. Or you have finished searching.Environment variables are originally available in Windows. You only need to modify them to point to the JDK bin directory, so that you do not need to enter a large number of paths when compiling and executing programs in the console. The setting method is to keep the original PATH content and add % JAVA_HOME % \ bin to it.

 

PATH and CLASSPATH both specify the PATH list. The items in the list (that is, each PATH) are separated by separators. In Windows, the Delimiter is a semicolon (;), while in Linux, The Delimiter is a colon (:).

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.