Ubuntu16.04 mounting java6 (jdk 1.6)

Download the installation package

First official website to download the installation package.

TIM picture 20191018003816.png

installation

input the command

chmod 777 jdk-6u45-linux-x64.bin
sudo ./jdk-6u45-linux-x64.bin

Move to the specified location and set the version

Create a new folder in java / usr / lib directory, installed in the previous step to move to the next folder in the directory

cd /usr/lib
sudo mkdir java
sudo mv jdk1.6.0_45/ /usr/lib/java

Then enter the following three commands

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/java/jdk1.6.0_45/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/java/jdk1.6.0_45/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/java/jdk1.6.0_45/bin/javaws" 1

Each of the last command 1is the priority when there are multiple versions of the system at the same time jdk

Set Environment Variables

sudo gedit ~/.bashrc

In the end of the file plus

#JAVA HOME directory setup
export JAVA_HOME=/usr/lib/java/jdk1.6.0_45
export PATH="$PATH:$JAVA_HOME/bin"

Save and exit, enter java -versiontest.

Note: Some online tutorials final step is to modify /etc/profile, I appeared that way path system commands can not find, can not lead to reboot into the system need to reinstall the system.

Switching java version

Sometimes there may be multiple versions of java inside the system, you can select the version they need through the following command.

sudo update-alternatives --config java

Guess you like

Origin www.cnblogs.com/multhree/p/11696084.html