Linux system Java environment configuration

1. Uninstall the JDK that comes with the Linux system

java -version

rpm -qa | grep -i java

 We need to delete the built-in JDK environment

rpm -e --nodeps java-1.6.0-openjdk-1.6.0.0-1.66.1.13.0.el6.i686
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.i686

Check again if it has been deleted

2. Install the JDK you downloaded

 2.1 Download JDK, address: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

I am using a 32-bit linux system, so I downloaded 32-bit. You can use the command to query whether it is 32-bit or 64-bit

getconf LONG_BIT

 2.2 Upload the JDK to the server and unzip it to the directory you created

mkdir -p /usr/local/java

Unzip the JDK to /usr/local/java below

tar -zxvf jdk-8u171-linux-i586.tar.gz -C /usr/local/java/
cd /usr/local/java/jdk1.8.0_171/

3. Configure environment variables

 3.1 Edit the linux environment variable file

vim /etc/profile

press i to insert

 3.2 Add java variable environment

#java config
JAVA_HOME=/usr/local/java/jdk1.8.0_171
CLASSPATH=.:$JAVA_HOME/lib/tools.jar
PATH=$JAVA_HOME/bin:$PATH
export JAVA_HOME CLASSPATH PATH

Press Esc to exit edit mode, type :wq to save

 3.3 Save the variable file and reload the variable

At this point, entering the java command will prompt

Reload the environment variable configuration file

source /etc/profile

4. Test whether the installation is successful

 Execute java, javac

java configuration is complete

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325365339&siteId=291194637