简体   繁体   中英

I installed JRE and JDK 8, but in Eclipse it shows Java/JavaVirtualMachines/1.6.0 JDK. What to do?

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!

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, eg 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, ie 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.

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

在此处输入图片说明 在此处输入图片说明

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM