Check the java version with the command java -version if it successfully installed then you can see the version else you will see the below image.
Java –version
If you get result similar to the below image you do not have Java installed. The list shows you which packages in your system have Java available and you have to install it.![chkjava](https://www.helicalinsight.com/wp-content/uploads/2019/09/chkjava1.jpg)
If you do not have the correct version of Java, please download Java 11 from here. ( Note: Oracle login might be required, if you do not have you can register for free and download)
Installation Steps:
- Check for Java Installation
- Login to Ubuntu
- Check if Java is not already installed or not using command java -version Installing OpenJDK 8:
- To install OpenJDK 8, execute the following command: sudo apt-get install openjdk-8-jre
- This will install the Java Runtime Environment (JRE). If you instead need the Java Development Kit (JDK), execute the following command: sudo apt-get install openjdk-8-jdk
- To set the JAVA_HOME environment variable, which is needed for some programs, first find out the path of your Java installation: sudo update-alternatives –config java
- /usr/lib/jvm/java-8-oracle
- /usr/lib/jvm/java-6-openjdk-amd64
- /usr/lib/jvm/java-7-oracle
- Copy the path from your preferred installation and then edit the file /etc/environment: sudo nano /etc/environment
- In this file, add the following line (replacing YOUR_PATH by the just copied path): JAVA_HOME=”YOUR_PATH”
- Test it by executing:
It returns something like:
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status:
* 0 /usr/lib/jvm/java-8-oracle/jre/bin/java 1062 auto mode
1 /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-7-oracle/jre/bin/java 1062 manual mode
Press enter to keep the current choice[*], or type selection number:
The path of the installation is for each:
That should be enough to set the environment variable. Now reload this file:
source /etc/environment
If it returns the just set path, the environment variable has been set successfully. If it doesn’t, please make sure you followed all steps correctly.