2

I've been having

Exception in thread "main" java.lang.UnsupportedClassVersionError: Unsupported major.minor version 51.0

So I looked it up, and then updated both my JRE and JDK to 8th version.

But above the console, it displays:

System/Library/Java/JavaVirtualMachines/1.6.0 JDK ....

How do I make my Eclipse run in 8th version of JDK and JRE? And do I need to change anything in my projects after upgrading?

Thanks in advance!

drillau
  • 25
  • 1
  • 10
  • Set your JAVA_HOME correctly. – SWiggels Sep 04 '15 at 07:21
  • 2
    JAVA_HOME can also be set in eclipse.ini : http://stackoverflow.com/questions/23174265/how-to-specify-jdk-path-in-eclipse-ini-on-windows-8-when-path-contains-space – Tarun Gupta Sep 04 '15 at 07:24
  • 1
    Eclipse start script can configurations can be modified using eclipse.ini -vm option [Check this](http://stackoverflow.com/questions/23174265/how-to-specify-jdk-path-in-eclipse-ini-on-windows-8-when-path-contains-space) – Tarun Gupta Sep 04 '15 at 07:25

3 Answers3

3

In Eclipse:

  • Select pull-down menu: Windows > Preferences
  • On left, select Java > Installed JREs
    • Click "Add..." and browse to your JDK/JRE folder
    • Rename if desired, e.g. change "jdk1.8.0_51" to "jdk1.8"
    • Repeat if you want access to more JDK/JRE versions in Eclipse workspace
    • Check the JRE you want to be the default for your projects
  • On left, select Java > Compiler
    • Set compliance level to match the default JRE

Note: If your projects don't use the workspace default, then you need to update the project Properties.


Eclipse itself is running with the default Java, i.e. the java on your PATH. If you want Eclipse to run using a different JDK/JRE, you need to edit the eclipse.ini file. See the link provided by Tarun Gupta.

Community
  • 1
  • 1
Andreas
  • 154,647
  • 11
  • 152
  • 247
0

In Eclipse you have to change the Java location like below steps

enter image description here enter image description here

SaviNuclear
  • 886
  • 1
  • 7
  • 19
0

Check for:

1) Proper java environment variable setup.

2) Right click on Project name in Project Explorer in Eclipse.
    Click on Build Path -> Configure Build Path.
    Check for proper path for Java Build Path. Also check whether the latest version of Java is     selected in Java Compiler -> Compiler Compliance Level.

3) Check from command line which Java is installed by typing java -version or java.
(Sometimes Java installed from command line in Linux systems installs old versions)

Zoran777
  • 564
  • 2
  • 7
  • 25