安装 java 8:update-alternatives:错误:备用路径 /usr/lib/jvm/jdk1.8.0/bin/java 不存在

安装 java 8:update-alternatives:错误:备用路径 /usr/lib/jvm/jdk1.8.0/bin/java 不存在

我知道这个问题看起来像是重复的问题,但我认为不是。我正在尝试在我的 ubuntu 14.04 LTS 上安装 java 8。我尝试了很多方法,但都不起作用。所以我下载了jre-8u25-linux-x64.tar.gz。然后我做了以下事情:

tar -xvf jre-8u25-linux-x64.tar.gz 
sudo mkdir -p /usr/lib/jvm
sudo mv ./jdk1.8.0_25/ /usr/lib/jvm
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0/bin/java" 1

但我收到以下错误:

update-alternatives: error: alternative path /usr/lib/jvm/jdk/bin/java doesn't exist`

当我打开jdk1.8.0_25时没有找到bin/java,于是我重新下载了,但是还是出现同样的问题。

谁能告诉我我在这里做错了什么?

编辑

输出:update-alternatives --display java

update-alternatives: warning: alternative /opt/jdk/jdk1.8.0_05/bin/java (part of link group java) doesn't exist; removing from list of alternatives
java - auto mode
  link currently points to /usr/lib/jvm/java-7-oracle/jre/bin/java
/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java - priority 1071
  slave java.1.gz: /usr/lib/jvm/java-7-openjdk-amd64/jre/man/man1/java.1.gz
/usr/lib/jvm/java-7-oracle/jre/bin/java - priority 1072
  slave java.1.gz: /usr/lib/jvm/java-7-oracle/man/man1/java.1.gz
Current 'best' version is '/usr/lib/jvm/java-7-oracle/jre/bin/java'.

答案1

执行完之后sudo mv ./jdk1.8.0_25/ /usr/lib/jvm,文件夹是 /usr/lib/jvm/jdk1.8.0_25创建了还是/usr/lib/jvm/jdk1.8.0创建了?

sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/**jdk1.8.0**/bin/java" 1

答案2

来自以下链接:https://www.digitalocean.com/community/tutorials/how-to-manually-install-oracle-java-on-a-debian-or-ubuntu-vps

update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_05/bin/javac 100

答案3

我有一个文件夹/usr/lib/java-8-openjdk-amd64,因此我为其创建了一个符号链接并将其命名为java-8-oracle。成功了。

相关内容