1

I've tried all the ways but somehow I can't install java 11. Showing my previous version of java

I did following steps:

STEP 1: I Installed : jdk-11.0.8_linux-x64_bin.deb file from Oracle website.

STEP 2: Run this command : sudo dpkg -i jdk-11.0.8_linux-x64_bin.deb

STEP 3: sudo get update

STEP 4: run this command sudo vim /etc/profile.d/jdk.sh

STEP 5: Add this line in empty folder:

export JAVA_HOME=/usr/lib/jvm/jdk-11.0.8/
export PATH=$PATH:$JAVA_HOME/bin

And save this file. Than I checked in usr/lib/jvm path with ls I get:

default-java@  java-1.8.0-openjdk-amd64@  java-8-openjdk-amd64/  jdk-11.0.8/

Than I enter this command:

source /etc/profile.d/jdk.sh

I get these output:

    set: Warning: path component /usr/lib/jvm/jdk-11.0.8/bin:/home/duygu/bin may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /home/duygu/bin'?
set: Warning: path component /usr/lib/jvm/jdk-11.0.8/bin:/home/duygu/.local/bin may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /home/duygu/.local/bin'?
set: Warning: path component /usr/lib/jvm/jdk-11.0.8/bin:/usr/local/sbin may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /usr/local/sbin'?
set: Warning: path component /usr/lib/jvm/jdk-11.0.8/bin:/usr/local/bin may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /usr/local/bin'?
set: Warning: path component /usr/lib/jvm/jdk-11.0.8/bin:/usr/sbin may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /usr/sbin'?
set: Warning: path component /usr/lib/jvm/jdk-11.0.8/bin:/usr/bin may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /usr/bin'?
set: Warning: path component /usr/lib/jvm/jdk-11.0.8/bin:/sbin may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /sbin'?
set: Warning: path component /usr/lib/jvm/jdk-11.0.8/bin:/bin may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /bin'?
set: Warning: path component /usr/lib/jvm/jdk-11.0.8/bin:/usr/games may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /usr/games'?
set: Warning: path component /usr/lib/jvm/jdk-11.0.8/bin:/usr/local/games may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /usr/local/games'?
set: Warning: path component /usr/lib/jvm/jdk-11.0.8/bin:/snap/bin may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /snap/bin'?
set: Warning: path component /usr/lib/jvm/jdk-11.0.8/bin:/usr/local/jdk-11.0.2/bin may not be valid in PATH.
set: No such file or directory
set: Did you mean 'set PATH $PATH /usr/local/jdk-11.0.2/bin'?

When I check the java -version I get: openjdk version "1.8.0_265"

And enter this command : update-java-alternatives --list I get:

java-1.8.0-openjdk-amd64       1081       /usr/lib/jvm/java-1.8.0-openjdk-amd64

I tried sudo reboot and tried again and I didnt install java 11 . How can I install ? Where is my fault ?

EDITED:

I've already tried this lines:

sudo add-apt-repository ppa:linuxuprising/java

sudo apt-get update

sudo apt-get install openjdk-11-jdk

I get error like this:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package openjdk-11-jdk is a virtual package provided by:
  oracle-java15-installer 15-1~linuxuprising3
  oracle-java14-installer 14.0.2-1~linuxuprising1
  oracle-java11-installer-local 11.0.8-1~linuxuprising0
You should explicitly select one to install.

E: Package 'openjdk-11-jdk' has no installation candidate
hobik
  • 439
  • 4
  • 15
  • 1
    Why the complicated installation using downloads and not use `apt-get install openjdk-11-jdk`, as suggested in https://stackoverflow.com/questions/52504825/how-to-install-jdk-11-under-ubuntu. Also this should be on https://askubuntu.com/ – Fullslack Sep 30 '20 at 08:57
  • Ive already tried but I get error I mentioned about it new edited – hobik Sep 30 '20 at 09:11
  • @matt how can I solve this? – hobik Sep 30 '20 at 09:14
  • I found this installation method in https://computingforgeeks.com/how-to-install-java-11-on-ubuntu-debian-linux/ So I am using this steps – hobik Sep 30 '20 at 09:16
  • @matt I have already tried installing them I get a has no installation candidate error in all of the recommended installations – hobik Sep 30 '20 at 09:23
  • But also I've tried like export PATH=$JAVA_HOME/bin:$PATH and it does not work – hobik Sep 30 '20 at 09:25
  • I’m voting to close this question because it is more of a question for askubuntu.com It also needs more focus. It's just chaos at the moment. – matt Sep 30 '20 at 09:27

2 Answers2

2

Just do this after installing,

sudo nano /etc/environment
JAVA_HOME="/usr/lib/jvm/jdk-11.0.8"

Note that, /bin is not to be included. Save and exit. Then,

source /etc/environment

Btw, why complicate a normal installation?

vicki
  • 402
  • 2
  • 8
  • Thank you for your reply. I added this lines and run source /etc/enviroment I get this error: Unsupported use of '='. In fish, please use 'set JAVA_HOME /usr/lib/jvm/jdk-11.0.8'. /etc/environment (line 2): JAVA_HOME="/usr/lib/jvm/jdk-11.0.8" – hobik Sep 30 '20 at 12:50
  • @hobik I thought you were using bash shell. In fish shell, setting a variable is different. Try In set command, I don't know if `quotes` can be used or not. Try `set JAVA_HOME /usr/lib/jvm/jdk-11.0.8` or `set JAVA_HOME '/usr/lib/jvm/jdk-11.0.8'` – vicki Sep 30 '20 at 13:07
0

You can probably install java 11 by the following command

sudo add-apt-repository ppa:linuxuprising/java

sudo apt-get update

sudo apt-get install openjdk-11-jdk

You can refer this link to see how to install openjdk 11 on ubuntu.

Then you can run the

update-alternatives --config java

to update the java version. You can refer this link to see how to update java alternatives.

  • When I did all those things, I tried your suggestion but I get error I will add in my topic please look again. – hobik Sep 30 '20 at 09:08
  • Try adding `sudo add-apt-repository ppa:openjdk-r/ppa` instead of `sudo add-apt-repository ppa:linuxuprising/java` then run the installation commands – Kasun Piyasena Sep 30 '20 at 09:26