0
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 " "
7

1 Answer 1

1

The immediate solution is to take sudo out of the script and run the script using sudo script-file.

A perhaps better solution is to use Web Upd8's package that takes care of installing Oracle's Java 8 for you, including updating it via apt upgrade when new versions come out.

This can be done in the terminal with:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .