Java 7 – How to Use Java 7 from Eclipse


I installed openjdk-6-jre from the package manager, then I installed Eclipse, and this was the default JRE.

Now I needed to install, in addition to 6, also Java 7, so I installed openjdk-7-jre from the package manager. However, in Eclipse I still see only JRE 6. Also from the command line I see only java 6:

$ java -version
java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.5) (6b24-1.11.5-0ubuntu1~12.04.1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

How can I use JRE 7 from Eclipse?

Best Answer

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


To know the location of your JVM run -

> sudo find / -name rt.jar

The output on my system is -


This tells me that jdk is in /usr/lib/jvm/