Issue
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
Solution
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?
Answered By - vicki
Answer Checked By - Katrina (JavaFixing Volunteer)