Windows configuration JDK

Source: Internet
Author: User

First, JDK1.6 download

Currently the latest JDK version is JDK1.6, to http://java.sun.com/javase/downloads/index.jsp can download JDK1.6.

Second, JDK1.6 installation

The installation of the JDK is very simple, just follow the wizard step after step. The installation path must be remembered during installation and will be used when configuring environment variables. My installation path is f:jdk1.6.

Third, configure environment variables

For beginners, the configuration of environment variables is more error-prone, and should be carefully configured in the process. There are three environment variables that need to be configured with the JDK: Java_home, Classpath, and path (case insensitive).

1, Java_home

Right click on "My Computer", select "Properties", click "Advanced" tab and select "Environment variables". Enter the following dialog box:

In the System variables bar, click on the "New" button, the following dialog box appears:



Fill in the variable name Java_home, the value of the variable fill in the f:jdk1.6, and then click OK, so the Java_home variable is configured to complete.

2, Classpath

can refer to the Java_home configuration process, you need to create a new system variable, but the CLASSPATH variable name is classpath, variable value is .; %java_home%\lib; %java_home%\lib\tools.jar (to be added . Represents the current path).

3. Path

The path variable already exists in the system variable, and to modify the path variable you only need to select the path variable and click Edit. Add the following to the value of the variable:%java_home%\bin;%java_home%\jre\bin. It is recommended to place the path of the JDK bin at the front of the original path. Because there is also a java.exe/javaw.exe in the%SystemRoot%\System32, this is the Windows operating system comes with the JRE, if we do not use his default JRE, you can use our own installed. If you put the path of the JDK bin to the front, it will be preferred.

The purpose of configuring Java_home,classpath,path:

1, set Java_home:

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.
First, for the convenience of reference, for example, your JDK installed in the C:\ProgramFiles\Java\jdk1.6.0 directory, then set Java_home as the directory path, then you want to use this path, just enter%java_home%, Avoid entering a long path string for each reference;
Second, the principle, when you are forced to change the JDK path, you only need to change the value of the java_home variable, otherwise, you will change any of the absolute path references to the JDK directory of the document, if you do not change the whole, a program can not find the JDK, the consequences are imagined----system crashes!

      2. Settings classpath:
    The role of the     CLASSPATH environment variable is to specify a class search path, and to use a class that has already been written, the premise is to be able to find them, and the JVM is looking for classes through classpth. 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. The purpose of this variable setting is for the program to find the corresponding ". Class" File, for example: You compile a Java program---a.java, you will get a A.class class file, you execute Java A in the current directory, you will get the corresponding results ( The premise is that you have set the Classpath to "."). Now, you move the a.class to a different directory (for example: "E:\"), execute Java A, there will be Noclassdeffinderror exception, because the. class file is not found, now you add Classpath to: ".; E:\ "Run Java A again to see what will happen ~ ~:) ~ ~ ~, everything is OK, java command found the. class file through Classpath!

3. Set Path:
The reason is simple, you want to use%java_home%\bin\java and so on at any time to execute JAVA commands, of course, you can choose to add%java_home%\bin to path path, so, We can use Java to execute commands under any path. (When you enter your code in the Command Prompt window, the operating system looks for the appropriate application in the current directory and path variable directory, and executes the.). The role of the PATH environment variable is to specify the command search path, and execute the command below the DOS command line, such as Javac compiling the Java program, it will look in the path specified by a 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, and the bin directory contains the frequently used executables such as Javac/java/javadoc wait, and after setting the path variable, you can execute the Javac/java tool in any directory.

Iv. Installation and Inspection

Under the DOS window, type the java-version command to see the JDK version information for the installation, type Java commands to see Help for this command, and type the Javac command to see Help for this command. If you see it as you wish, the JDK installation is successful.

Windows configuration JDK

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.