英文:
Java 11 installation problem for Ubuntu 16.04
问题
我尝试了所有方法,但不知何故无法安装Java 11。显示我先前的Java版本。
我按照以下步骤操作:
步骤1: 我从Oracle网站安装了jdk-11.0.8_linux-x64_bin.deb
文件。
步骤2: 运行此命令:sudo dpkg -i jdk-11.0.8_linux-x64_bin.deb
步骤3: 运行此命令:sudo get update
步骤4: 运行此命令:sudo vim /etc/profile.d/jdk.sh
步骤5: 在空文件夹中添加以下行:
export JAVA_HOME=/usr/lib/jvm/jdk-11.0.8/
export PATH=$PATH:$JAVA_HOME/bin
然后保存此文件。然后我在usr/lib/jvm
路径下使用ls
命令进行检查,我得到:
default-java@ java-1.8.0-openjdk-amd64@ java-8-openjdk-amd64/ jdk-11.0.8/
然后我执行了以下命令:
source /etc/profile.d/jdk.sh
我得到了以下输出:
set: 警告:路径组件 /usr/lib/jvm/jdk-11.0.8/bin:/home/duygu/bin 可能在PATH中无效。
set: 没有那个文件或目录
set: 你是不是想说 'set PATH $PATH /home/duygu/bin'?
...
当我检查java -version
时,我得到:openjdk version "1.8.0_265"
然后我执行以下命令:update-java-alternatives --list
,我得到:
java-1.8.0-openjdk-amd64 1081 /usr/lib/jvm/java-1.8.0-openjdk-amd64
我尝试了sudo reboot
,然后再次尝试,但我仍未安装Java 11。我应该如何安装?我哪里出错了?
编辑:
我已经尝试了以下命令:
sudo add-apt-repository ppa:linuxuprising/java
sudo apt-get update
sudo apt-get install openjdk-11-jdk
我得到类似于以下的错误:
正在读取软件包列表... 完成
正在构建依赖关系树
正在读取状态信息... 完成
软件包 openjdk-11-jdk 是一个虚拟软件包,由以下提供:
oracle-java15-installer 15-1~linuxuprising3
oracle-java14-installer 14.0.2-1~linuxuprising1
oracle-java11-installer-local 11.0.8-1~linuxuprising0
你应该明确选择一个进行安装。
E: 软件包 'openjdk-11-jdk' 没有可安装的候选项
英文:
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
答案1
得分: 2
只需在安装后执行以下操作,
sudo nano /etc/environment
JAVA_HOME="/usr/lib/jvm/jdk-11.0.8"
注意,不要包括 /bin
。保存并退出。然后,
source /etc/environment
顺便问一下,为什么要让正常安装变得复杂呢?
英文:
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?
答案2
得分: 0
你可以使用以下命令安装Java 11:
sudo add-apt-repository ppa:linuxuprising/java
sudo apt-get update
sudo apt-get install openjdk-11-jdk
你可以参考这个链接了解如何在Ubuntu上安装OpenJDK 11。
然后,你可以运行以下命令来更新Java版本:
update-alternatives --config java
你可以参考这个链接了解如何更新Java备选版本。
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论