About setting up Java environment variables

Source: Internet
Author: User

Java products are installed, and environment variables are set, otherwise it won't work. The programming language that requires the installation environment also has the Python,go language.

This article describes how Java sets environment variables.

There are 3 main environment variables used in JAVA under Windows, Java_home, CLASSPATH, and PATH. The following is analyzed individually.

Java_home points to the installation path of the JDK, such as C:\jdk1.5.0_06, you should be able to find the bin, Lib and other directories under this path. It is worth mentioning that the installation path of the JDK can choose any disk directory, but it is recommended that you put a shallow directory level, if you put a deep directory, such as x:\XXXXXX\xxxxx\XXXX\xxxx\XXXX\xxxx\XXXX\xxx ...
Then, the following steps and later application you will be affected, hehe. Setup method:

java_home=c:\jdk1.5.0_06

The path environment variable is already in Windows, you just have to modify it to point to the JDK Bin directory, so you do not need to type a large string of paths when compiling and executing the program under the console. The Setup method is to keep the contents of the original path, and add%java_home%\bin (note, if you do not understand the DOS batch, you may not understand what is meant by the content of the percent), in fact, this is a reference to the previous set of environment variables Java_home, you write x:\ jdk_1.4.2 is also possible; you can open a console window and enter echo%java_home% to see your settings:

path=%java_home%\bin;%path%


Again,%path% is referencing the PATH environment variable you set earlier, and you can copy the previous value.

CLASSPATH Environment variables I put in the last side, because you appear in the inexplicable strange problem 80% or more may be due to the CLASSPATH settings are not caused, so be more careful.


classpath=.; %java_home%\lib;%java_home%\lib\tools.jar


The first thing to note is the front ".;", if you can't see clearly, I'll read it to you-a period semicolon. This is to tell the JDK to search the class for the current directory's class file-why, this is due to the security mechanism of Linux, Linux users understand that the Windows users are very difficult to understand (because the Windows default search order is the first to search the current directory , then search the system directory, and then search the PATH environment variable set), so if you like quickness Friends may wish to study Linux.
Why is Tools.jar this specific file specified later in classpath? Don't specify a line? Obviously not, I can still do that. :) This is determined by the import mechanism and jar mechanism of the Java language, and you can check the data to resolve it.


Hehe, the specific setting method: win2k\xp The user right click on My Computer, properties--- advanced environment Variables , modify the value of the box below the system variable is OK.
Win9x The user modifies the Autoexec.bat file and adds it at the end:


Set java_home=c:\jdk1.5.0_06
Set path=%java_home%\bin;%path%
Set classpath=.; %java_home%\lib;%java_home%\lib\tools.jar

Of course there are other variants of the Windows system version that are set up in the same way.

About setting up 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.