[JAVA] How to install multiple JDKs on Ubuntu 18.04 LTS

This is a summary of how to install multiple JDKs (Java Development Kits) on Ubuntu 18.04 LTS.

Installation

  1. Execute the sudo add-apt-repository ppa: linuxuprising / java command to add the repository.
  2. Execute the sudo apt update command to update the package list.
  3. Run the sudo apt install default-jre command to install the default JRE.
    * If there is software that does not correspond to the version of JDK set as the default, it may be solved by using this JRE.
  4. Do this for all the JDKs you want to install:
  5. Run the sudo apt install oracle-java * -installer command to install the JDK.
    * Enter the JDK version ( 8 for Java 8) in*.

Setting

  1. 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.

  2. Run the sudo update-alternatives --config java command and select the default java command.

  3. Run the sudo update-alternatives --config javac command and select the default javac command.

  4. Run the sudo update-alternatives --config javaws command and select the default javaws command.

  5. 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
    
  6. Execute the source ~ / .bashrc command.

  7. Execute the java -version command, and if the version of JDK to be set as the default is displayed, it is successful.

References

Recommended Posts

How to install multiple JDKs on Ubuntu 18.04 LTS
How to install WildFly on Ubuntu 18.04
How to install production Metabase on Ubuntu
How to Install Elixir and Phoenix Framework on Ubuntu 20.04 LTS
How to install java9 on elementaryOS Freya or Ubuntu 14.04 LTS
How to install NVIDIA driver on Ubuntu 18.04 (Note)
How to Install Oracle JDK 1.8 in Ubuntu 18.04 LTS?
Install raspi-config on Ubuntu 20.04 (LTS)
Install WordPress 5.5 on Ubuntu 20.04 LTS
How to install NVIDIA driver on Ubuntu ssh destination
How to install ImageMagick on Windows 10
How to use Bio-Formats on Ubuntu 20.04
How to install MariaDB 10.4 on CentOS 8
How to build vim on Ubuntu 20.04
How to install Eclipse (Photon) on Mac
How to install beta php8.0 on CentOS8
How to change the timezone on Ubuntu
How to install kafkacat on Amazon Linux2
How to install and use Composer on an ECS instance on Ubuntu 16.04
How to install and configure the monitoring tool "Graphite" on Ubuntu
How to install Adopt OpenJDK on Debian, Ubuntu with apt (-get)
How to configure ubuntu to be used on GCP
How to install c2ffi on Ubuntu, which automatically parses C header files
Install pyqt5 on ubuntu
Install Ruby on Ubuntu 20.04
How to install Docker
How to install docker-machine
Install Autoware on Ubuntu 18.04.5
Install and switch between multiple Javas on Ubuntu
Apache2 on Ubuntu20.04 LTS
How to install MySQL
Install Homebrew on Ubuntu 20.04
[Ruby on Rails] How to install Bootstrap in Rails
How to build a Pytorch environment on Ubuntu
How to run NullpoMino 7.5.0 on Ubuntu 20.04.1 64bit version
How to install ngrok
How to install Ruby on an EC2 instance on AWS
Install MySQL 5.6 on CentOS6 [How to specify the version]
Building WebGIS on Ubuntu20.04 LTS
Install OpenJDK7 (JAVA) on ubuntu 14.04
Install Cybozu Office 10 on Ubuntu 20.4
Install Docker on Ubuntu Server 20.04
[Rails] How to install devise
How to deploy on heroku
Install MAV Proxy on Ubuntu 18.04
Install Arudino IDE on Ubuntu 20
Record video on ubuntu18.04 LTS
Installing OpenMX on Ubuntu 18.04.5 LTS
Install Java on WSL Ubuntu 18.04
How to install Boots Faces
Install Ubuntu Desktop 20.10 on RaspberryPi4
Install Arduino IDE on Ubuntu 20.04
Install PlantUML on Intellij on Ubuntu
Install Ubuntu Server 20.04 on Btrfs
Note: Install PostgreSQL 9.5 on Ubuntu 18.04
[Rails] How to install simple_calendar
[Rails] How to install reCAPTCHA
How to install JDK8-10 (Mac)
How to add HDD to Ubuntu
Install Ubuntu MATE 20.04 LTS on older MacBook Early 2008 (MB402 * / A, MB403 * / A, MB404 * / A)
How to run npm install on all projects in Lerna