Installing the JDK and configuring the Java Operating environment

Source: Internet
Author: User

Installing the JDK and configuring the Java Operating environment

1.jdk:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html.

  

2. Click on Accept License agreement to download the JDK for your computer version. Since my computer is WINDOWS10 64-bit Professional Edition, I chose the last one.

  

Click the Red download button. The save location is your own decision, as long as you can find it when you install it.

3. Locate the installation file and double-click it.

  

4. Next, this will let you choose the installation directory.

Note: It is best not to select the source installation directory, because you find that program files contain spaces, later compiled Java software may be error, 1:30 will not find the problem where, so in case of prevention, here is recommended to install to other directories above. I personally choose to create a new file in D to call him Java, open the Java folder, create a new two folder inside, a called JDK, a JRE called.

  

5. Go back to the original installation screen, change the installation directory to the new JDK file. Click Next.

  

6. After installing the JDK, the installation interface of the JRE will be ejected. Here, select the installation path below the new JRE folder.

  

7. Click Next. The JDK and JRE are then successfully installed. Click Close.

  

8. Test that the JDK is installed successfully. Here we teach you a shortcut key. Windows+r Open the Run interface. Enter CMD to open the DOS system.

  

9. Click Run. Enter Java. If the following is displayed, the installation is successful.

  

10. But when you enter Javac, this is displayed. This is because you have not configured the Java Runtime Environment, then teach you how to configure the Java Runtime Environment, configure the running environment can use the full java.

  

11. Right-click PC properties to turn on advanced system settings.

12. Click Advanced, then click Environment Variables.

  

13. New system variable java_home, variable value fill D:\Java\jdk1.8.0_131, (this is the installation path of my JDK, you install on the other disk to find the JDK installation path to copy in the line)

 

14. Find the Pathin your system variable, double click, Find the Edit text click, add at the end of the variable value ;%java_home%\bin;%java_home%\jre\bin

  

15. New system variable CLASSPATH, variable value fill .; %java_home%\lib;%java_home%\lib\dt.jar;%java_home%\lib\tools.jar(Note that the value of this variable is preceded by a point that represents the current path)

  

16. Click OK, then to test the following javac can be used, windows+r key open run, enter cmd, open the DOS system, enter javac-version or Java-version.

  

What is Classpath? What is the role of it?
It is an environment variable of the Javac compiler.
Its role is related to import, the package keyword.
When you write down Improt java.util.*, when the compiler faces the import keyword, you know you want to introduce java.util the class in the package, but how does the compiler know where you put the package? So you first have to tell the compiler where the package is located, and how do you tell it? is to set classpath:) If java.util this package in the C:\jdk\ directory, you have to set c:\jdk\ this path to Classpath! When the compiler faces the import java.util.* this statement, it first looks for the directory specified by Classpath and checks to see if the subdirectory java\util exists, and then finds the compiled file (. class file) that matches the name. If you do not find it will be an error!
Classpath is a bit like the settings of the include path in the C\c++ compiler oh, isn't it? When the C\c++ compiler encounters a statement such as include <iostream>, how does it work? Oh, the truth is almost the same! Search the Include path to view the file!
When you develop a package yourself, and then want to use the class in the package, naturally, you also have to set the directory where the package resides in Classpath!
Classpath's setting is a tricky thing for beginners in Java. So Sun made JAVA2 's jdk a little bit smarter. You will find that after you install, you can still compile the basic Java program and execute it even if you have not set classpath at all.

......................................................................................................................... ............................

1. Path environment variable. The function is to specify the command search path, execute the command below the command line, such as Javac compiling the Java program, it will look in the path specified by the paths variable to see if the corresponding 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.

2. classpath environment variables. The role is to specify the class search path, to use the already written classes, the premise of course is to find them, the JVM is through Classpath to find the class of the. class file. 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.

Javac-c Path (You can specify a class file to store the directory)

JAVA-CP Path (You can specify the class directory to execute)

3. 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.

On the Windows desktop, right-click "My Computer", "Properties", "Advanced", "Environment variables", in "system variables" we can see the values of the system's various environment variables. Double-click a variable name to modify the value of the variable, using ";" between the variable values. Separated. We can also "create new" variables that were not previously available. There are 3 environment variables associated with the JDK, "java_home", "path", "Classpath". The "path" variable already exists in my system, can add the new value directly (other variable values do not move, prevent other programs to run the exception), the other two variables need to be new.

"Java_home", set the JDK installation path, such as "e:\Java\jdk1.8.0_131", hereinafter referred to as "%java_home%".

"Path", set the path of each program in the JDK, "%java_home%\bin;%java_home%\jre\bin;"

"Classpath", set the path of each class in Java, ".; %java_home%\lib;%java_home%\lib\dt.jar;%java_home%\lib\tools.jar ". The previous "." No less, it represents the working path we have built for our Java class, and the other is the standard class library path that comes with the JDK.

After setting the environment variable, press OK to exit. Press "Win" + "R" key into the "Run" window, run "cmd" into the DOS window, enter "Javac" after entering, if there is help information showing Java, the environment variable setting is successful.

CLASSPATH = ".; %java_home%\lib;%java_home%\lib\dt.jar;%java_home%\lib\tools.jar "

Java_home = "C:\Program files\java\jdk1.8.0_131"

Path = "%java_home%\bin;%java_home%\jre\bin"

Installing the JDK and configuring the Java Operating environment

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.