我试图在我的 ubuntu 14.04 机器上安装 java8。我收到以下错误。我尝试了互联网上提供的多种解决方案,但每次都会重复出现以下错误。
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of oracle-java8-set-default:
oracle-java8-set-default depends on oracle-java8-installer; however:
Package oracle-java8-installer is not configured yet.
dpkg: error processing package oracle-java8-set-default (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Errors were encountered while processing:
oracle-java8-installer
oracle-java8-set-default
E: Sub-process /usr/bin/dpkg returned an error code (1)
提前致谢..
答案1
我尝试过很多解决方案,但这对我有用解决方案。我发布这篇文章是为了帮助其他人
Create an empty folder so that we can install java 1.8
sudo mkdir /opt/java && cd /opt/java
Now lets download java-1.8 version
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u45-b14/jdk-8u45-linux-x64.tar.gz"
Extract the tar file
tar -zxvf jdk-8u45-linux-x64.tar.gz
Now lets update the alternatives so that system will point to the location where java-1.8 is installed
cd jdk1.8.0_45/
sudo update-alternatives --install /usr/bin/java java /opt/java/jdk1.8.0_45/bin/java 100
Note: The 100 in above command represents the priority no. which can set manually
sudo update-alternatives --config java
Please enter the selection no. which is having the path as “/opt/java/jdk1.8.0_45/bin/java” and press enter.
sudo update-alternatives –install /usr/bin/javac javac /opt/java/jdk1.8.0_45/bin/javac 100
sudo update-alternatives –config javac
sudo update-alternatives –install /usr/bin/jar jar /opt/java/jdk1.8.0_45/bin/jar 100
sudo update-alternatives –config jar
Now lets try to set up the environment variables