3. Java development environment set up: Install JDK, configure the environment variables

1, the installation JDK development environment

Download site: http://www.oracle.com/

6b9eaac7-7ad0-4267-9319-e6e15b32c9cf [1]

dd697eb7-69ef-4361-9d6a-954cb9816056 [1]

d8902921-5d36-4c68-adf4-b82b56f1c68c

Start the installation JDK:

d47ed425-94b4-4413-83dd-c62d8081168f[1]

Modify the installation directory as follows:

77aa84d8-4f3b-44cd-9461-327a7962286f [2]

After determining, click "Next."

Note: When prompted to install the JRE, you can choose not to install.

2, configure the environment variables:

For Java developers, the main two commands will use the JDK: javac.exe, java.exe. Path: C: \ Java \ jdk 1.7.0 _09 \ bin. However, these command windows because it does not belong to their own command, so if you want to use, you need to configure the path. 

Click "Computer - Properties - Advanced System Settings", click "environment variables." Under "System Variables" toolbar, click "New" to create a new system environment variables.

50aa00df-6bb9-471c-81a7-363845b6f2b3

(1) New -> variable name "JAVA_HOME", variable value "C: \ Java \ jdk1.8.0_05" ( ie JDK installation) 
(2) Edit -> variable name "Path", the last of the original face value of the variable plus ";% JAVA_HOME% \ bin;% JAVA_HOME% \ jre \ bin" 
(3) New -> variable name "CLASSPATH", variable value ";% JAVA_HOME% \ lib; % JAVA_HOME% \ lib \ dt.jar. ;% JAVA_HOME% \ lib \ tools.jar "

 

Such as: operating the JAVA_HOME environment variable is as follows:

23f073bb-cc49-43c1-8da1-099f9c18dda3 [3]

01747df9-c309-438d-a6f7-ea68f43c416c [1]

3, identification of environmental configuration is true:

Input java, javac, java -version console command respectively, the JDK compiler information shown below, including modifying the command syntax and parameter information options, occur.

java command:

3aa10479-a799-4805-b97f-c99c9f4c698c[1]

08c7092a-0487-46c1-9d45-024867dfc5e2[4]

javac command:

6fa0a9a4-77f6-413f-bbdc-9f7afe093061[4]

java -version command:

c458fc01-02e6-4c27-b5bb-3fce15202360[4]

4, the first java program verification in console:

public class Test {
    public static void main(String[] args) {    
    System.out.println("Hello Java");
    }
}

Good use Notepad to write, click "Save" and stored in the root directory C, enter javac Test.java and java Test command, you can run the program (print out the result "Hello Java"). Note: These two commands are in D: \ java \ jdk1.8.0_20 under the \ bin directory.

Program analysis:

 

First written in java source code program, the extension .java;

In the command mode, enter the command: javac .java source file name, source code is compiled to produce byte code class files;

After compilation, if there is no error message, enter the command: java HelloWorld, for the class file byte code interpreted to run, no need to add the .class extension when executed. See below:

 

Note: If you enter the command javac test.java CMD, the display 'javac' is not an internal or external command, the reason is because there is no pre-configured incorrectly installed JDK development environment or an environment variable. 

Guess you like

Origin www.cnblogs.com/mztl-1122/p/11819211.html