What JRE to use for JDK 14?

最后都变了- 提交于 2021-01-21 03:46:18

问题


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?


回答1:


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




回答2:


  • There is no seperate JRE for JDK 14.
  • You just need to install the JDK 14 and set the path in Environment Variables like, C:\Program Files\Java\jdk-14.0.2\bin
  • To verify whether it was successful, close and 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



回答3:


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.




回答4:


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! 🙂




回答5:


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.




回答6:


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




回答7:


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



来源:https://stackoverflow.com/questions/60983814/what-jre-to-use-for-jdk-14

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!