I've installed the default jdk by issuing the command:
apt-get install default-jdk
This will install openjdk 11 and apt-get seems to install the files all over the place. Examples:
/etc/java-11-openjdk/management
/usr/lib/jvm/java-11-openjdk-amd64/lib
/usr/share/doc/openjdk-11-jre-headless/JAVA_HOME
/var/lib/dpkg/info/openjdk-11-jre:amd64.postinst
As you can see by the example locations above, there are files scattered everywhere.
I've just installed a web app that's giving a warning that it only supports jdk 12 (I think it's the latest openjdk version). How can I install version 12 so that it replaces version 11? What is the best way to upgrade the openjdk version on Ubuntu 18.04 so that it doesn't mingle with the previous version?
This works for me:
wget https://download.java.net/java/GA/jdk12.0.2/e482c34c86bd4bf8b56c0b35558996b9/10/GPL/openjdk-12.0.2_linux-x64_bin.tar.gz
sudo mkdir /usr/java
mv openjdk-12.0.2_linux-x64_bin.tar.gz /usr/java
cd /usr/java
sudo tar -xzvf openjdk-12.0.2_linux-x64_bin.tar.gz
sudo nano /etc/profile
JAVA_HOME=/usr/java/jdk-12.0.2
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
export PATH
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk-12.0.2/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk-12.0.2/bin/javac" 1
java -version
If you previously had another version of Java installed and the version has not changed, try to run the following command and to select the desired version:
sudo update-alternatives --config java
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With