0

When I run the file through command shell I get this error:

Exception in thread "main" java.lang.UnsupportedClassVersionError: packageCalculator/Calculator 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

When I run: java - version

I get: java version "1.8.0_281" Java(TM) SE Runtime Environment (build 1.8.0_281-b09) Java HotSpot(TM) Client VM (build 25.281-b09, mixed mode, sharing)

Does Eclipse use a java version greater than current VM? Please help to solve the problem

user1238784
  • 2,250
  • 3
  • 22
  • 41
  • Eclipse is shipped with an embedded Java 15 used to run Eclipse. Configure the Java JREs/JDK in _Window > Preferences: Java > Installed JREs_ you want to use in your projects. Eclipse does not use `javac`, but has its own incremental Java Compiler that compiles to the Java version you have configured in your project (_Project > Properties: Java Compiler_). – howlger Apr 17 '21 at 08:59
  • You can tell Eclipse exactly what version settings to use for the Project in the Project Properties - look at the Java Compiler page. Class file version 59 is Java 15, 52 is Java 8 – greg-449 Apr 17 '21 at 09:00
  • Ok, I know how to setup eclipse with another JRE, but why the java VM I downloaded from Oracle is so obsolete? – user1238784 Apr 17 '21 at 09:04
  • The current Java from the Oracle download page [here](https://www.oracle.com/java/technologies/javase-downloads.html) is actually Java 16 (Eclipse needs a patch to support 16, that page also has a Java 15 download) – greg-449 Apr 17 '21 at 09:10
  • but then i have to download the sdk and I have to give all sort of information about my business to oracle. – user1238784 Apr 17 '21 at 09:13
  • If you don't want to agree to the Oracle license you can use the [OpenJDK](https://openjdk.java.net/) versions - same code, different license, less frequent updates – greg-449 Apr 17 '21 at 09:15
  • ok, thx i downloaded and installed the oracle version of sdk 16 but I still see that java version is unchanged: from java configuration I see it's the most updated. – user1238784 Apr 17 '21 at 09:23
  • See my comment above. You might consider to ship your Java application with a Java JRE, e.g. from https://adoptopenjdk.net/ (using Java 9 or higher, you can create via `jlink` a JRE with a minimal system library containing only those modules that are required by your application). – howlger Apr 17 '21 at 10:17

0 Answers0