Jdk1.6 environment variable configuration in Windows

Source: Internet
Author: User

1. Download jdk1.6

The latest JDK version is jdk1.6. You can download JDK 1.6at http://java.sun.com/javase/downloads/index.jsp.

Ii. jdk1.6 Installation

JDK installation is very simple. You only need to follow the wizard step by step. Remember the installation path during installation. This installation path will be used when configuring environment variables. My installation path is F: jdk1.6.

3. Configure Environment Variables

For beginners, environment variable configuration is relatively error-prone and should be carefully configured. To use JDK, you must configure three environment variables: java_home, classpath, and path (Case Insensitive ).

1. java_home

Right-click "my computer", select "properties", click the "advanced" tab, and select "environment variable ". Enter the following dialog box:

In the system variables column, click "new" to bring up the following dialog box:

 

 

Enter java_home in the variable name, F: jdk1.6 in the variable value, and click OK. Then, the java_home variable is configured.

2. classpath

You can refer to the configuration process of java_home and create a new system variable. However, the classpath variable name is classpath and the variable value is.;% Java_home % \ Lib;% Java_home % \ Lib \ tools. Jar (add.Indicates the current path ).

3. Path

The PATH variable already exists in the system variable. to modify the PATH variable, you only need to select the PATH variable and click Edit. Add the following content to the variable value: % java_home % \ bin; % java_home % \ JRE \ bin. We recommend that you put the JDK bin path at the beginning of the original path. Because there is a java.exe/javaw.exe in % SystemRoot % \ system32, which is the JRE that comes with the Windows operating system. If we install it ourselves, we should not use the default JRE, we can install it on our own. If you put the JDK bin path at the beginning, it will be used first.

 

Configure java_home, classpath, and Path:

1. Set java_home:

Java_home environment variable. It points to the JDK installation directory. Eclipse, netbeans, tomcat, and other software find and use the installed JDK by searching the java_home variable.
1. For reference convenience, for example, if your JDK is installed in the c: \ Program Files \ Java \ jdk1.6.0 directory, set java_home to the directory path, to use this path in the future, you only need to enter % java_home % to avoid entering a long path string for each reference;
Ii. Normalization principle: when your JDK path is forced to change, you only need to change the variable value of java_home. Otherwise, you need to change any document that uses the absolute path to reference the JDK directory, if you fail to complete the changes and a program cannot find the JDK, the consequence is that the system crashes!

2. Set classpath:
The classpath environment variables are used to specify the Class search path. To use the classes that have already been compiled, the premise is that they can be found. The JVM uses classpth to find classes. We need to set DT. jar and tools. jar in the Lib subdirectory under the JDK installation directory to classpath. Of course, the current directory "." must also be added to this variable. This variable is set so that the program can find the corresponding ". class "file, for example: you compile a Java program ---. java,. class class file. If you execute Java A in the current directory, the corresponding result will be obtained (provided that you have set classpath ". "). now. when the class is moved to another directory (for example, "E: \") and Java A is executed, there will be a noclassdeffinderror exception because it cannot be found. class file, now you add classpath :".; e: \ "run Java A again to see what the result will be ~~ :)~~~, Everything is normal. The Java Command finds the. Class file through classpath!

3. Set path:
The principle is very simple. Do you want to use % java_home % \ bin \ Java to execute Java commands at any time? Of course not, so, you can add % java_home % \ bin to the path. In this way, we can use Java to execute commands in any path. (When you enter your code in the Command Prompt window, the operating system will find the corresponding application in the current directory and PATH variable directory and execute .). The Path Environment Variable specifies the command search path. Execute the command below the doscommand line, for example, when javac compiles a Java program, it will go to the path specified by the PATH variable to check whether the corresponding command program can be found. We need to add the bin directory under the JDK installation directory to the existing PATH variable. The bin directory contains frequently used executable files such as javac/Java/javadoc waiting, after setting the PATH variable, You can execute tools such as javac and Java in any directory.

Iv. Installation check

In the DOS window, enter the Java-version command to view the installed JDK version information. Enter the Java command to view the help information of this command; enter the javac command to view the help information of this command. If you see it as expected, the JDK is successfully installed.

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.