This is a summary of how to install multiple JDKs (Java Development Kits) on Ubuntu 18.04 LTS.
sudo add-apt-repository ppa: linuxuprising / java
command to add the repository.sudo apt update
command to update the package list.sudo apt install default-jre
command to install the default JRE. sudo apt install oracle-java * -installer
command to install the JDK. 8
for Java 8) in*
.Execute the sudo apt install oracle-java * -set-default
command to set the JDK environment.
* In *
, enter the JDK version ( 8
for Java 8) to be set as the default.
Run the sudo update-alternatives --config java
command and select the default java
command.
Run the sudo update-alternatives --config javac
command and select the default javac
command.
Run the sudo update-alternatives --config javaws
command and select the default javaws
command.
Execute the nano ~ / .bashrc
command and add the following.
JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:/bin/javac::")
export JAVA_HOME
PATH=$PATH:$JAVA_HOME/bin
export PATH
Execute the source ~ / .bashrc
command.
Execute the java -version
command, and if the version of JDK to be set as the default is displayed, it is successful.
Recommended Posts