Notes from reconfiguring
JAVA_HOMEwhile switching from OpenJDK 8 to 11
sudo apt-get install openjdk-11-jdk- This command also installs the
openjdk-11-jrepackage which contains the Java runtime environment!
chloe@chloe-XPS-15-9570 ~
$ java -version
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1, mixed mode, sharing)-
You can find the installed JDKs by navigating to the
/usr/lib/jvm/pathchloe@chloe-XPS-15-9570 ~ $ cd /usr/lib/jvm/ chloe@chloe-XPS-15-9570 /usr/lib/jvm $ ls default-java java-11-openjdk-amd64 java-8-openjdk-amd64 java-1.11.0-openjdk-amd64 java-1.8.0-openjdk-amd64 openjdk-11
Open
/etc/environmentwith vim
sudo vi /etc/environmentAdd the following environment variable
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export JAVA_HOME
Apply the modified values immediately using the
sourcecommand
source /etc/environmentchloe@chloe-XPS-15-9570 /usr/lib/jvm
$ echo $JAVA_HOME
/usr/lib/jvm/java-11-openjdk-amd64chloe@chloe-XPS-15-9570 /usr/lib/jvm
$ printenv | grep "java"
JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64- Using
grepallows you to search for a specific string!- Here we are searching for "java"!
Done!
+
chloe@chloe-XPS-15-9570 ~
$ sudo update-alternatives --config java
[sudo] password for chloe:
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 <enter> to keep the current choice[*], or type selection number:
- You can change to the desired version by entering its number