15

There is a message

Project has been compiled by a more recent version of the Java Runtime (class file version 57.0), this version of the Java Runtime only recognizes class file versions up to 52.0

I googled "JRE required for JDK 14" and there is no download to be found. In my Java control panel on Windows 10, it says I have the latest version of the Java platform. I cannot downgrade the JDK on my project since I am using a library which was completely compiled on Java 14. How (and where) does one upgrade the JRE to match with Java 14 and support version 57?

Mark Rotteveel
  • 82,132
  • 136
  • 114
  • 158
Thicc
  • 169
  • 1
  • 1
  • 3
  • 3
    _"it says I have the latest version of the Java platform"_ and what version is that? – Phil Apr 02 '20 at 03:29
  • 3
    There has been **no** JRE since Java 11 (they only distribute a JDK now). You should learn about the module system and jlink (since Java 9). – Elliott Frisch Apr 02 '20 at 03:29
  • 1
    So ... given Elliott's (correct) comment ... the simplest solution is to install a Java 14 JDK. You can (currently) get the Oracle version from https://www.oracle.com/java/technologies/javase-downloads.html and the OpenJDK version as per here: https://openjdk.java.net/install/. But only until Java 14 goes end-of-life. – Stephen C Apr 02 '20 at 03:55
  • @ElliottFrisch How are you supposed to run software compiled on JDK 14? – Thicc Apr 02 '20 at 16:33
  • @StephenC I already have JDK 14. I need a JRE that is capable of running projects compiled on JDK 14. Java 8 update 241 (the latest Oracle JRE version) cannot do this apparently. – Thicc Apr 02 '20 at 16:34
  • 2
    @Thicc Your clients must: install JDK 14 **or** you use [`jlink`](https://docs.oracle.com/javase/9/tools/jlink.htm#JSWOR-GUID-CECAC52B-CFEE-46CB-8166-F17A8E9280E9). I don't know why you keep searching for a thing that no longer exists. – Elliott Frisch Apr 02 '20 at 17:01
  • @ElliottFrisch So JDK and JRE are interchangeable terms? I thought the JDK is what compiles java programs and JRE is what runs them. I am searching for something that can run programs which have been compiled on JDK 14. – Thicc Apr 02 '20 at 17:25
  • 2
    @Thicc The Java Runtime Environment was discontinued with Java 11. Since 14 > 11, there is **no** JRE for Java 14. Instead, you are meant to learn about the new Java module system (added in Java 9) and `jlink` (also Java 9) which can be used to create custom runtime images of your application. Java 9 was released in September 2017. Java 11 in September 2018. It is now April 2020. And you are just **now** noticing? – Elliott Frisch Apr 02 '20 at 17:32
  • 3
    *"I thought the JDK is what compiles java programs and JRE is what runs them."* - That is where you are wrong. A JRE **only** runs Java. A JDK compiles Java **and also** runs Java. This is why a JDK >>will<< work for you. This has always been the case. – Stephen C Apr 02 '20 at 23:16
  • @StephenC I'm not certain the distinction matters, but the JDK included the JRE **plus** Java hosted development tools. So saying the JDK runs Java *feels* a little bit off. The JRE ran Java. And "tools.jar" was the only part you needed to compile Java code. Of course, that changed with Java 11 so I guess it's moot. – Elliott Frisch Apr 03 '20 at 14:42
  • 1
    @ElliottFrisch - the key words are the ones that I bolded: **only** and **and also** – Stephen C Apr 03 '20 at 15:34
  • 1
    @ElliottFrisch - I am contrasting what Thicc thought (incorrectly) with the actual facts. My my two short sentences are not intended to be (even) a summary of JRE versus JDK capabilities. The are solely intended to be a concise correction to the misconception which was causing Thicc to not understand what we are saying to him. – Stephen C Apr 03 '20 at 15:40
  • 2
    Related: https://stackoverflow.com/questions/53111921/how-to-get-java-11-run-time-environment-working-since-there-is-no-more-jre-11-fo Not exactly a duplicate, as it was for Java 11, but the same applies to any more recent version. – Didier L Apr 06 '20 at 11:58

7 Answers7

9

I assume you are using a Java version / build that is coming from Oracle on your machine. Since Java 11 the Oracle Java does not automatically update and install any new JRE on your system. Next to this Oracle does not provide JRE builds for Java 11+ anymore. You can only download JDKs from Oracle (Oracle JDK).

While Oracle provides an alternative with the Oracle JDK builds (see https://jdk.java.net/14/) you can not get a JRE here.

A very good alternative is AdoptOpenJDK that provides JREs for Java 14 here: https://adoptopenjdk.net/releases.html?variant=openjdk14&jvmVariant=hotspot

Hendrik Ebbers
  • 2,447
  • 17
  • 33
9
  • There is no seperate JRE for JDK 14.
  • You just need to install the JDK 14 and set the path in Environment Variables like, Variable name= JAVA_HOME & Variable value= C:\Program Files\Java\jdk-14.0.2\bin
  • To verify whether it was successful, close & reopen the command prompt and type java.
  • To check the Java version, type in command prompt javac -version . Should produce something like javac 14.0.2
Matthew
  • 1,710
  • 4
  • 19
  • 47
  • If your system has Java 8 pre-installed, this won't work. you must go to https://adoptopenjdk.net/releases.html?variant=openjdk14&jvmVariant=hotspot and download JRE and re-install it! – Luke Aug 12 '20 at 14:40
  • Why not uninstall it and install fresh JDK14 if you actually want a JDK 14 to be installed on your system? – Matthew Aug 13 '20 at 15:09
  • i just want to have only jre 14 and did not know about the change (ni separate jre from v11) – Luke Aug 13 '20 at 16:56
5

Since Java 9 there is no JRE provided due to the platform modularization introduced through Project Jigsaw. If you want one, you should build it yourself using jlink with only those modules you really need.

If you just want to run your project you can use any JDK which supports Java 14.

dan
  • 595
  • 4
  • 12
bish
  • 3,075
  • 8
  • 41
  • 62
3

Don’t panic! You have solved the problem with a simple and fast hand trick. And here you can learn how to do it.

If you have encountered this (or a similar) error message the problem is quickly solved.

“Error: A JNI error has occurred, please check your installation and try again
Exception in thread “main” java.lang.UnsupportedClassVersionError: Main has been compiled by a more recent version of the Java Runtime (class file version 56.0), this version of the Java Runtime only recognizes class file versions up to 52.0″

The problem occurs because your JRE (Java Runtime Enviroment) and your JDK (Java Development Kit) are not working together correctly. Usually the problem occurs when you want to call a .jar file by comment line, e.g. with the command java -jar File.jar.

Troubleshoot

To fix the bug, you only need to adjust the environment variables for Java.

To do this, you navigate by typing “env” in your Windows search and open the item “Editing System Environment Variables”. In this window click on “Environment Variables…”.

The “Enviroment Variables” window opens. There you select the variable “Path” in the lower window and click on “Edit…”.

There you look for the line where the installation path of your JDK is stored. In this case it is under C:\Program Files\Java\jdk-13.0.1\bin.

If you do not have this entry in your database, you can add it by clicking the “New” button. If you have not yet installed the JDK, you can do so here.

When you have found the line, click on “Move Up” until the entry is at the top of the list. Done!

Now you have to close and reopen the Windows CMD once and the error should be fixed. I hope this post could solve your problem!

EJ201
  • 31
  • 1
0

You can run your aplication direct from the JDK 14, try this on console:

"c:\Program Files\Java\jdk-14\bin\java" Main

Where the quoted path is the folder where you JDK is installed and the Main is the .class file you want to execute.

0

try to go on the properties of your Project and select java build path go on JRE System Library select edit and select Workspace default JRE PS: Im using Eclipse for coding java things if youre not using that program I can't help you sorry

-3

You probably may have the worng java version in your path.

Try running

java -version

This will show the JRE in classpath.

You can try downloading and installing the JRE from here -

https://adoptopenjdk.net/installation.html?variant=openjdk14&jvmVariant=hotspot#x64_win-jre

Pushkar
  • 6,990
  • 9
  • 35
  • 57
  • `java version "1.8.0_241" Java(TM) SE Runtime Environment (build 1.8.0_241-b07) Java HotSpot(TM) Client VM (build 25.241-b07, mixed mode)` Is this not sufficient to run something which has been compiled on JDK 14? – Thicc Apr 02 '20 at 04:01
  • No. You may want to install jre using the link in answer – Pushkar Apr 02 '20 at 08:37