Java-
Java and JVM both are required for running multiple software like Tomcat, Jetty, Glassfish and many more.
In this post i will install JRE and JDK using apt. You should know our Ubuntu 20.04 comes with Open JDK 11, which is an open-source variant of the JRE and JDK.
Install the JRE/JDK
please update the package index first
$ sudo apt update
$ sudo apt install default-jre
this open JRE will allow you to run almost all Java software.
$ java -version
You can check and verify this.
Now you think what about the JDK to compile and run java base software, To install JDK run the below command.
$ sudo apt install default-jdk
Set the JAVA_HOME
Environment Variable
For setting up java_home environment , check the location where your java is installed. use below command to get.
$ sudo update-alternatives --config java
Output like below if you follow above steps
There are 1 choices for the alternative java (providing /usr/bin/java). Selection Path Priority Status ------------------------------------------------------------ 0 /usr/lib/jvm/java-11-openjdk-amd64/bin/java 1111 auto mode
Now run
$ sudo nano /etc/environment
at the end of file append the below code,
JAVA_HOME="/usr/lib/jvm/java-11-openjdk-amd64"
Note- this is your java path might be in your system this is different “/usr/lib/jvm/java-11-openjdk-amd64”. Copy this path carefully.
Save the file and exit the editor.
For applying the change in current session use below command
$ source /etc/environment
and now all done, check you java version
$ echo $JAVA_HOME
Output
/usr/lib/jvm/java-11-openjdk-amd64
All Done.
Thanks , Happy coding.
1 Comment
Top site ,.. amazaing post ! Just keep the work on !