![安装 Oracle java 1.8 时出现问题](https://linux22.com/image/1122530/%E5%AE%89%E8%A3%85%20Oracle%20java%201.8%20%E6%97%B6%E5%87%BA%E7%8E%B0%E9%97%AE%E9%A2%98.png)
我正在运行 Ubuntu 14.04。我正在尝试安装 Oracle java 8。我下载了 Oracle 发布的 .rpm 文件: jdk-8u20-linux-x64.rpm然后运行以下命令尝试安装它:
$ sudo alien jdk-8u20-linux-x64.rpm --scripts
$ sudo dpkg -i jdk1.8.0-20_1.8.020-1_amd64.deb
这两个命令似乎运行正常,然后我尝试将 java 指向默认的这个命令,但使用以下命令失败:$ sudo update-java-alternatives -s java-8-oracle 我收到以下消息:
update-java-alternatives: directory does not exist: /usr/lib/jvm/java-8-oracle
我尝试查看有哪些可用版本:
$ sudo update-java-alternatives -l
java-1.7.0-openjdk-amd64 1071 /usr/lib/jvm/java-1.7.0-openjdk-amd64
知道可能是什么问题吗?
问候 C
答案1
1.下载java
http://www.oracle.com/technetwork/java/javase/downloads/index.html
2.打开终端输入命令
cd Downloads
tar xzvf jdk-8u25-linux-x64.tar.gz
sudo mkdir /usr/lib/jvm
sudo mv ~/Downloads/jdk1.8.0_25/ /usr/lib/jvm/
sudo chown -R root:root /usr/lib/jvm/jdk1.8.0_25
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_25/bin/java" 0
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_25/bin/javac" 0
sudo update-alternatives --set java /usr/lib/jvm/jdk1.8.0_25/bin/java
sudo update-alternatives --set javac /usr/lib/jvm/jdk1.8.0_25/bin/javac
sudo gedit ~/.bashrc
export JAVA_HOME=/usr/lib/jvm/jdk1.8.0_25
export PATH=$PATH:$JAVA_HOME/bin
. ~/.bashrc
java -version
echo $JAVA_HOME
echo $PATH