--Ubundle 16.04 currently supports two versions, JDK8 and JDK9, but here's how to get an older version of the JDK --This time, we will introduce JDK7 as an example.
Get the list for JDK 7 from the PPA repository
Execute the following command to get the list to install JDK7.
```terminal
$ sudo add-apt-repository ppa:openjdk-r/ppa
・ ・ ・ >Reading package lists... Done ```
Get a list of installable packages
Execute the following command to get a list of installable packages.
```terminal
$ sudo apt-get update
・ ・ ・ >Reading package lists... Done ```
Get the main body of JDK7
Execute the following command to get the main body of JDK.
```terminal
$ sudo apt-get install openjdk-7-jdk
```
Version switching
If you have multiple JDK versions installed, switch the JDK version (if you see the output below, enter the number at the beginning of the line for the version of the JDK you want to change and enter, this time Enter 1 because you want to use JDK7 Enter)
```terminal
$ sudo update-alternatives --config java
>There are 2 choices for the alternative java (providing /usr/bin/java).
>Selection Path Priority Status
>------------------------------------------------------------
>* 0 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 auto mode
>1 /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java 1071 manual mode
>2 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 manual mode
>Press <enter> to keep the current choice[*], or type selection number:
```
Check the version
Execute the following command to check the JDK version. (OK if it looks like the following)
```terminal
$ java -version
>java version "1.7.0_95"
>OpenJDK Runtime Environment (IcedTea 2.6.4) (7u95-2.6.4-3)
>OpenJDK 64-Bit Server VM (build 24.95-b01, mixed mode)
```
Recommended Posts