sudo tar -xvf $HOME/Desktop/Lesearch_Update/jdk-8u121-linux-x64.tar.gz -C $HOME/Downloads/
sudo rm -r /usr/lib/jvm
sudo mkdir -p /usr/lib/jvm/jdk1.8.0_121
sudo mv $HOME/Downloads/jdk1.8.0_121/* /usr/lib/jvm/java8/
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java8/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/java8/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/java8/bin/javaws" 1
sudo echo '"JAVA_HOME=/usr/lib/jvm/java8"' >> /etc/profile
sudo echo 'PATH=$PATH:$HOME/bin:$JAVA_HOME/bin' >> /etc/profile
sudo echo 'export JAVA_HOME' >> /etc/profile
sudo echo 'export JRE_HOME' >> /etc/profile
sudo echo 'export PATH' >> /etc/profile
sudo rm -r $HOME/Downloads/jdk1.8.0_121
echo "java 8 installed sucessfully.... :) "
echo " "
echo " "
答案1
立即的解决方案是取出sudo
脚本并使用运行该脚本sudo script-file
。
也许更好的解决方案是使用 Web Upd8 的包,它会负责为您安装 Oracle 的 Java 8,包括在apt upgrade
新版本发布时进行更新。
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer