我正在尝试安装 Java 8 但出现以下错误:
root@usr:~# sudo add-apt-repository ppa:webupd8team/java
sudo: add-apt-repository: command not found
经过一番研究后,我输入了以下解决方案:
root@usr:~# sudo apt-get install software-properties-common python-software-properties
但我收到此错误:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package python-software-properties is not available, but is referred to by another package.
This may mean that the package is missing, has been obsolete, or is only available from another source
E:Unable to locate package software-properties-common
E:Package 'python-software-properties' has no installation candidate
在此之后我尝试:
root@usr:~# sudo apt-get install software-properties-common
我收到以下错误信息:
E:Unable to locate package software-properties-common
我不知道还能做什么。你能帮忙吗?
答案1
如何安装最新的 Java JDK 和 JRE
下载 java jdk 和 jre
http://www.oracle.com/technetwork/java/javase/downloads/index.html
扩展到主目录:
~/jdk*
~/jre*
一旦两个目录都暂时位于你的主目录中,只需将以下所有内容剪切并粘贴到终端中
# ............ TOP of cut N paste >>>>>>>>>>>>>>>>>>>> #
sudo mkdir -p /usr/local/java
cd /usr/local/java
# remove previous installs if any
sudo rm -rf /usr/local/java/jdk*
sudo rm -rf /usr/local/java/jre*
# move downloaded into /usr/local/java
sudo mv ~/jdk* /usr/local/java/
sudo mv ~/jre* /usr/local/java/
cd /usr/local/java/
# create symbolic links
sudo ln -s jdk* jdk
sudo ln -s jre* jre
# ___ ONLY need to do below on fresh ubuntu install - not necessary if previously installed any java version as its already in place
# symlinks :
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/local/java/jre/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/local/java/jdk/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/local/java/jre/bin/javaws" 1
sudo update-alternatives --set java /usr/local/java/jre/bin/java
sudo update-alternatives --set javac /usr/local/java/jdk/bin/javac
sudo update-alternatives --set javaws /usr/local/java/jre/bin/javaws
java -version # run this to verify install worked
# ............ BOTTOM of cut N paste >>>>>>>>>>>>>>>>>>>> #
完成...确认一切正常,请发出
java -version
这应该给你类似
java version "1.8.0_102"
Java(TM) SE Runtime Environment (build 1.8.0_102-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.102-b14, mixed mode)