Installing and Configuring Java on Ubuntu (version 19)


administrator@slave1:~$ sudo apt install openjdk-8-jdk                            

administrator@slave1:~$ which java
/usr/bin/java

administrator@slave1:~$ readlink -f /usr/bin/java
/usr/lib/jvm/java-11-openjdk-amd64/bin/java

administrator@slave1:~$ 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-11-openjdk-amd64/bin/java      1111      auto mode
  1            /usr/lib/jvm/java-11-openjdk-amd64/bin/java      1111      manual mode
  2            /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java   1081      manual mode

Press  to keep the current choice[*], or type selection number: 2
update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java to provide /usr/bin/java (java) in manual mode

administrator@slave1:~$ java -version
openjdk version "1.8.0_222"
OpenJDK Runtime Environment (build 1.8.0_222-8u222-b10-1ubuntu1~19.04.1-b10)
OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)

=========================

Set the JAVA_HOME in the .bashrc file at path "~/.bashrc" and execute it to echo the "JAVA_HOME":

administrator@slave1:~$ echo $JAVA_HOME
/usr/lib/jvm/java-8-openjdk-amd64

TO INSTALL DEFAULT JDK: We'll install OpenJDK, the default Java Development Kit on Ubuntu 16.04.

First update package list:
sudo apt-get update

Then:
sudo apt-get install default-jdk

No comments:

Post a Comment