3

I have installed openJDK but want to default to regular JDK 11 (not OpenJDK). Steps I have taken:

1)java -version

openjdk version "11.0.7" 2020-04-14 OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-2ubuntu219.10) OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-2ubuntu219.10, mixed mode, sharing)`

2) sudo apt-get install oracle-java11-set-default-local

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package oracle-java11-set-default-local is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package 'oracle-java11-set-default-local' has no installation 

3) update-java-alternatives -l

java-1.11.0-openjdk-amd64 1111
/usr/lib/jvm/java-1.11.0-openjdk-amd64

4) Is it possible that I should just set the package installer to /usr/lib/jvm/jdk-11.0.7, instead of java-11-oracle? Top part of screenshot is the .deb file I downloaded from Oracle's site. Bottom part is what is saved in /usr/lib/jvm

7
  • Does this answer your question? Problems setting up Java on Ubuntu 19.10 – Raffa Apr 26 '20 at 18:47
  • @Raffa Thanks, but no. When I try sudo update-alternatives --config java the result is: There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-11-openjdk-amd64/bin/java Nothing to configure. – rbj Apr 26 '20 at 18:51
  • Then it looks like you have not installed Oracle Java correctly, see the instructions on the PPA page. You need to download installer from Oracle manually and place it the path described by package installer. – N0rbert Apr 26 '20 at 20:47
  • @N0rbert - thanks would you kindly check #4 above before I go that route? I already downloaded the .deb file from Oracle and believe it's installed? – rbj Apr 26 '20 at 21:00
  • The linuxuprising's installer expects that you have downloaded jdk-11.0.7_linux-x64_bin.tar.gz and placed it in location, see updated answer. – N0rbert Apr 26 '20 at 21:12
1

It looks like you are trying to install package from PPA, but forgot to add the PPA.

So you have to do the following:

Download the jdk-11.0.7_linux-x64_bin.tar.gz from https://www.oracle.com/java/technologies/javase-jdk11-downloads.html and copy it to cache location

sudo mkdir -p /var/cache/oracle-jdk11-installer-local
sudo cp jdk-11.0.7_linux-x64_bin.tar.gz /var/cache/oracle-jdk11-installer-local/

sudo add-apt-repository ppa:linuxuprising/java
sudo apt-get update
sudo apt-get install --reinstall oracle-java11-set-default-local

and then reboot.


To force Oracle Jave default use

sudo update-java-alternatives --set /usr/lib/jvm/java-11-oracle
2
  • Thanks! I ran this. How do I check to ensure default is now java instead of openjdk. Do I do this in the IDE (Netbeans)? When running java -version I see openjdk version "11.0.7" 2020-04-14 OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-2ubuntu219.10) OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-2ubuntu219.10, mixed mode, sharing) – rbj Apr 26 '20 at 19:57
  • It says the file doesn't exist. I checked and this directory exists but is empty: sudo update-java-alternatives --set /usr/lib/jvm/java-11-oracle update-java-alternatives: file does not exist: /usr/lib/jvm/.java-11-oracle.jinfo – rbj Apr 26 '20 at 20:45
1

Somehow openjdk was overwritting jdk, so I put /app/lang/java/jdk-11.0_64 at the end of my .bashrc file and it's fixed

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.