Set up a Java development environment-install jdk and configure environment variables

How to build a Java development environment.


Window system install java

Download JDK

First, we need to download the java development kit JDK, the download address: http://www.oracle.com/technetwork/java/javase/downloads/index.html , click the download button as follows:

On the download page, you need to choose to accept the license and choose the corresponding version according to your own system. This article uses the Window 64-bit system as an example:

After downloading, install the JDK according to the prompts, and also install the JRE when installing the JDK, just install it together.

Install JDK, you can customize the installation directory and other information during the installation process, for example, we choose the installation directory as C:\Program Files (x86)\Java\jdk1.8.0_91 .

Configure environment variables

1. After the installation is complete, right-click "My Computer", click "Properties", and select "Advanced System Settings";

2. Select the "Advanced" tab and click "Environmental Variables";

Then the screen shown below will appear:

Set 3 attributes in "System Variables", JAVA_HOME, PATH, CLASSPATH (the case does not matter), click "Edit" if it already exists, click "New" if it does not exist.

Note: If you use JDK version 1.5 or higher, you can compile and run Java programs normally without setting the CLASSPATH environment variable.

The variable setting parameters are as follows:

  • Variable name: JAVA_HOME
  • Variable value: C:\Program Files (x86)\Java\jdk1.8.0_91        // Configure according to your actual path
  • Variable name: CLASSPATH
  • Variable value: .;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;         //Remember that there is a "." in front
  • Variable name: Path

  • Variable amount: % JAVA_HOME% \ bin;% JAVA_HOME% \ jre \ bin;

JAVA_HOME settings

PATH setting

Note: In Windows 10, the Path variable is displayed separately, we need to add %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin; separately, otherwise it will not be recognized:

%JAVA_HOME%\bin;
%JAVA_HOME%\jre\bin;

For more information, please refer to: Windows 10 configure Java environment variables

CLASSPATH setting

This is the Java environment configuration. After the configuration is complete, you can start Eclipse to write code, and it will automatically complete the java environment configuration.

Test whether the JDK is installed successfully

1. "Start" -> "Run", type "cmd";

2. Key in the commands: java -version , java , javac , and the following information appears, indicating that the environment variable configuration is successful;


Guess you like

Origin blog.csdn.net/sunzheng176/article/details/113405434