Linux JDK8 apt installation and environment variable JAVA_HOME configuration

88a17d864d7a9dc1db1d688486908e6d.png

Table of contents

1. Update the software source

2. Install openjdk-8-jdk

3. Verify that the JDK installation is successful

4. Configure JAVA_HOME

5. Verify JAVA_HOME


 

Foreword to Avoid the Pit: Since Oracle has changed the version agreement of jdk8, we cannot use the ppa source to install it

In other words, the online ppa source tutorials are all invalid (if you don’t believe me, look at the time, most of them were before April 19)

It took a long time to find out

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBATm9ydGhlcm4gICBDcmVzY2VudA==,size_20,color_FFFFFF,t_70,g_se,x_16

 Oracle Java (JDK) 8 Installer PPA (DISCONTINUED) : “WebUpd8” team

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBATm9ydGhlcm4gICBDcmVzY2VudA==,size_20,color_FFFFFF,t_70,g_se,x_16

This article demonstrates under Ubuntu, Debian operation is the same, Redhat and centos are the same

 

Since Oracle's jdk cannot be installed directly with the package manager, we use open jdk , which is similar

 

1. Update the software source

sudo apt update

2. Install openjdk-8-jdk

sudo apt install openjdk-8-jdk

3. Verify that the JDK installation is successful

java -version

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBATm9ydGhlcm4gICBDcmVzY2VudA==,size_20,color_FFFFFF,t_70,g_se,x_16

4. Configure JAVA_HOME

sudo gedit /etc/profile

Add these things at the end of the file (the jdk installation directory is changed according to your own)

export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64  #jdk安装目录
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBATm9ydGhlcm4gICBDcmVzY2VudA==,size_20,color_FFFFFF,t_70,g_se,x_16

Ctrl+s to save and exit 

 

Make the configuration file take effect

sudo source /etc/profile

5. Verify JAVA_HOME

echo $JAVA_HOME

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBATm9ydGhlcm4gICBDcmVzY2VudA==,size_12,color_FFFFFF,t_70,g_se,x_16

 

Guess you like

Origin blog.csdn.net/m0_52559040/article/details/123682235