To make your new Java 7 installation the default one run this on shell -
> sudo update-alternatives --config java
To simply use Java 7 in your project without making it the system default go to Configure Built Path
> Libraries
> Add Library
> JRE System Library
> Installed JREs
> Add
> Standard VM
> Directory
and select the location where you installed the JVM.
Also change the Properties
> Java Compiler
> Compliance Level
to 1.7
Edit:
To know the location of your JVM run -
> sudo find / -name rt.jar
The output on my system is -
/usr/lib/jvm/jdk1.6.0_37/jre/lib/rt.jar
/usr/lib/jvm/jdk1.7.0_09/jre/lib/rt.jar
This tells me that jdk
is in /usr/lib/jvm/
This is caused by the fact that the PPA maintainer hasn't updated their scripts yet and older updates of Java 8 are no longer available from Oracle.
To quickly resolve this, you can do the following and install 8u151. (This will only work so long as 8u151 is available from Oracle)
1) Install as normal:
echo debconf shared/accepted-oracle-license-v1-1 select true | sudo
debconf-set-selections
echo debconf shared/accepted-oracle-license-v1-1 seen true | sudo debconf-set-selections
sudo add-apt-repository ppa:webupd8team/java
sudo apt update
Once that is done and you get the error:
Oracle JDK 8 is NOT installed.
dpkg: error processing package oracle-java8-installer (--configure):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
oracle-java8-installer
E: Sub-process /usr/bin/dpkg returned an error code (1)
2) You will then have to do the following for 8u151 to be installed:
cd /var/lib/dpkg/info
sudo sed -i 's|SHA256SUM_TGZ="e8a341ce566f32c3d06f6d0f0eeea9a0f434f538d22af949ae58bc86f2eeaae4"|SHA256SUM_TGZ="c78200ce409367b296ec39be4427f020e2c585470c4eed01021feada576f027f"|' oracle-java8-installer.*
sudo sed -i 's|JAVA_VERSION=8u144|JAVA_VERSION=8u151|' oracle-java8-installer.*
sudo sed -i 's|J_DIR=jdk1.8.0_144|J_DIR=jdk1.8.0_151|' oracle-java8-installer.*
sudo sed -i 's|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/$FILENAME|PARTNER_URL=http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/$FILENAME|' oracle-java8-installer.*
3) Once you complete the above, you can run the install again and it will succeed.
sudo apt install -y oracle-java8-installer
Best Answer
In Ubuntu 16.04-20.04 open the terminal and type:
Eclipse Preferences in Ubuntu 16.04
After you install openjdk-8-jdk the results of
update-java-alternatives -l
will look similar to this:If you have installed more than one version of Java there will be multiple lines in the results of
update-java-alternatives -l
however openjdk-8-jdk will work with everything, so you don't need to install another version of Java.