Home >php教程 >PHP开发 >Complete steps for setting java environment variables under Linux

Complete steps for setting java environment variables under Linux

高洛峰
高洛峰Original
2016-12-17 13:36:471483browse

Complete steps for setting java environment variables under Linux:

Download the JDK installation file from java.sun.com, usually in the format of jdk1.5.0_10_XXXX.bin.

Unlock and generate the JDK directory. It is assumed that the JDK is installed in /usr/java/jdk1.5.0_10:

Code:

sudo chmod 755 jdk1.5.0_10_XXXX.bin

sudo ./jdk1.5.0_10_XXXX.bin

sudo mkdir /usr/java

sudo mv jdk1.5.0_10/ /usr/java

Code:

sudo gedit /etc/profile

Append at the end of this file:

Code:

export JAVA_HOME =/usr/java/jdk1.5.0_10/

# Pay attention to append the bin directory of the newly added JDK at the front of $PATH, so that when there are multiple JDK versions installed in the system, the program will search first and rank it first The previous JDK version.

export PATH=$JAVA_HOME/bin:$PATH

export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$CLASSPATH

After saving /etc/profile, don’t forget To execute the following command, the changes to the environment variables will take effect immediately.

Code:

source /etc/profile

If an error is reported when executing the above command, please carefully check whether the text you added in /etc/profile is wrong.

Finally check whether the environment variable changes have taken effect:

Code:

java -version



For more related articles on the complete steps of setting java environment variables under Linux, please pay attention to 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