Install JDK/JRE for Ubuntu
…
There are two versions of JDK/JRE can be installed on Ubuntu:
- Open JDK/JRE
- Oracle JDK/JRE
Install Open JDK/JRE
Open JDK/JRE can be easily installed by
1 | sudo apt install default-jre |
Install Oracle standalone JRE
- First of all download Oracle JRE from Oracle
- Unpack downloaded package and install it into the path you like(i.e /usr/lib/java)
1
2cd /usr/lib/java
sudo tar -zxvf ~/Downloads/jre-8u231-linux-x64.tar.gz - Add JRE installation path into $PATH Add :/usr/lib/java/jre1.8.0_231 into PATH
1
sudo nano /etc/environment
- Add installed java as alternative To switch to other alternative java. use:
1
sudo update-alternatives --install /usr/bin/java java /usr/lib/java/jre1.8.0_231/bin/java 1
1
sudo update-alternatives --config java
- Check installation
1
2
3
4java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)