-1

I am trying to run a Java Application in Eclipse. I ran it about a month ago and it worked, and I can't think of what has changed. When I try to run it now, I get this error:

java.lang.UnsupportedClassVersionError: data_validation/Validation has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 52.0

I believe that what is happening is that it was compiled using Java 15 (class file version 59) but I'm trying to run it in Java 8 (class file version 52). This website explains it: https://all-learning.com/java-lang-unsupportedclassversionerror/ and here is a more complete list of class file versions: https://javaalmanac.io/bytecode/versions/

The only problem is, I never installed Java 15. Under C:\Program Files\Java, I just have jdk1.8.0_161. So how is it compiling in Java 15 and how to I tell Eclipse to compile and run in Java 8?

Thanks!

  • Eclipse has its own compiler and can compile for any version regardless of the Java you have installed. Look in the Preferences in 'Java > Compiler' and 'Java Compiler' in the Project Properties – greg-449 Jul 15 '21 at 06:29

1 Answers1

0

(Sorry for my bad english and the quality of the answer, it's the first I do)

Hi, first you need to configure Eclipse with a different version of Java:

Let's take a look at

Window -> Preferences

and then

Java -> Installed JREs

If the JRE you want is listed, you're good to go. Otherwise, you'll need to add the JRE to Eclipse:

From the same Preferences dialog, click the Add button located to the right, then choose Standard VM and click Next. Now you can select the JRE folder (in your case it should be the 1.8.0_161).

Now you have to change the project's JRE:

Right click on your project -> Build Path -> Configure Build Path.

Select the JRE and click the Edit button. Now choose Alternate JRE and select your Java 8 installation, then click

Finish -> Apply and Close.

Now you have to change the Compiler Level:

Go back to your Project Properties, then Java Compiler, and then check Enable project specific settings and now you can set the Compiler compilance level on 1.8.

Note: if you can't change the compilance level, you just need to uncheck "Use compilance from execution envirnoment on the 'Java Build Path'"

I hope I was helpful! Bye!

Crih.exe
  • 502
  • 4
  • 16