Configuration of JDK environment variables in Java

Source: Internet
Author: User

The JDK configuration is

Configuration in window, My Computer--Properties--Advanced system settings--advanced--environment variable configuration, specific

User variable refers to this configuration in effect in the current user

A system variable refers to this configuration that is in effect in the current system

The environment variables that the JDK needs to configure include

Java_home: Configuring the installation directory to the JDK

PATH: Configured as%java_home%\bin;%java_home%\jre\bin; " Or a direct "%java_home%\bin;

Classpath:%java_home%\lib\dt.jar;%java_home%\lib\tools.jar; "

Detailed

There are 3 main environment variables used in JAVA under Windows, Java_home, CLASSPATH, and PATH.

Java_home points to the installation path of the JDK, such as C:\jdk1.7, you should be able to find the bin, Lib and other directories under this path.

(Tonight with the new system configuration, do not know how to add bin to run in Cmd, Java_home=c:\jdk1.5.0_06\bin; The following is the online finishing practice can be used, note that the JDK and eclipse must be the same bit bits to use, Can not be a different number of programs, has been practice, or to error can not be used; If you need to uninstall JDK,JDK can not directly delete the folder, to use the uninstall method, or can no longer use the JDK or can not uninstall, only reinstall the OS to use, previously encountered)

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 preserve the contents of the original path and add the%java_home%\bin

(Note, if you do not understand DOS batch processing, you may not understand what is meant by the content of the percent of the java_home, in fact, this is a reference to the previous set of environment variables, you can write x:\JDK_1.4.2 is also possible; you can open a console window and enter the Echo%java _home% look at your setup results)

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 for the PATH environment variable set).
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.


Specific settings: Right-click My Computer, properties----Advanced environment variables, modify the value of the box below the system variable is OK.

The user modifies the txt text attribute auto.bat file and joins 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

Inspection: Run java-version in the Window command windows to view JDK version information. As shown 1.7.0 proves successful.

Configuration in Linux:

  

1)vi/etc/profile (Linux configuration is in this file)

2) Add in tail line

#set Java Environment (remarks, for setting up the Java environment)

Java_home=/usr/local/src/java/jdk1.7.0_51

Java_bin=/usr/local/src/java/jdk1.7.0_51/bin

Path= $JAVA _home/bin: $PATH

Classpath=.: $JAVA _home/lib/dt.jar: $JAVA _home/lib/tools.jar

Export Java_home java_bin PATH CLASSPATH

Save exit

3)source/etc/profile ( make change configuration effective immediately )

4)java-version view JDK version information. As shown 1.7.0 proves successful.

  

Configuration of JDK environment variables in Java

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.