Home >Java >JavaBase >How to configure java

How to configure java

尚
Original
2019-11-19 16:54:446061browse

How to configure java

window system installation java

Download JDK

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

How to configure java

In the download page, you need to choose to accept the license and adjust it according to your system Select the corresponding version. This article takes the Window 64-bit system as an example:

How to configure java

After downloading, install the JDK according to the prompts. When installing the JDK, the JRE will also be installed. and install it.

Install JDK. During the installation process, you can customize the installation directory and other information. 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";

How to configure java

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

How to configure java

Then the following will appear: Screen:

How to configure java

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

Note: If you use JDK version 1.5 or above, 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 there is a "." in front

  • Variable name: Path

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

JAVA_HOME Settings

How to configure java

How to configure java

##PATH Settings

How to configure java

How to configure java

CLASSPATH setting

How to configure java

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

Test whether the JDK is installed successfully

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

2. Type the command : java -version, java, javac several commands, the following information appears, indicating that the environment variable configuration is successful;

How to configure java

Linux, UNIX, Solaris, FreeBSD environment variable settings

The environment variable PATH should be set to point to the location where the Java binaries are installed. If you have trouble setting up, please refer to the shell documentation.

For example, assuming you are using bash as your shell, you can add the following to the end of your .bashrc file: export PATH=/path/to/java:$PATH

More For java knowledge, please pay attention to

java basic tutorial.

The above is the detailed content of How to configure java. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn