Reputation: 4941
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?
Upvotes: 13
Views: 16761
Reputation: 1550
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
Upvotes: 34
Reputation: 7
The official package repository from Ubuntu doesn't provide a Openjdk12 package because openjdk11 is the last version of the openjdk package for your version.
Upvotes: -2