Where to download JRE 11
I downloaded a fresh JDK 11 yesterday and installed it, but an error occurs.
Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.UnsupportedClassVersionError: hel has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
As I understand it, this is due to the fact that JDK 11, and the code compiled on it, but on my computer the java version is different (the eighth), but the question is, where can I download JRE 11? The official website of the Oracle offers only the eighth version. Don't beat me just for this question, I'm trying to learn, and yesterday 11 Java came out so I downloaded it.
4 answers
There is no JRE in Java 11. If you are a developer, you can run your program using JDK 11. If you want to do this from the command line, you should make sure that the path to java
or to java.exe
from JDK11 is set, in the environment variable PATH
, before the path to java
or to java.exe
of older JREs. At the same time, you should take into account that in Windows, the installers of the old Public JRE copied java.exe
to the C:\Windows\System32
directory, which is also registered in PATH
. It's best to just delete the old Public JRE. You don't have to delete the old JDK, it won't hurt.
If you want to send your program to an end user who now does not have a suitable JRE and does not want to install the JDK, you should create a runtime environment (some kind of old JRE) that will include only the necessary Java modules, including the module of your program.
For example, let's analyze a simple Hello world. Let your program consist of a single class com.example.MainClass
and is a module tryout
, that is, except com/example/MainClass.java
you have and module-info.java
(in the default package, i.e. above com
) with the module description. For example, with the following minimum:
module tryout {
}
By the way, in IntelliJ IDEA, adding a module is a separate operation from adding a class to the New
menu. You can't create module-info.java
the same way you create a regular class.
After building your project, for example, using Maven, you will get a jar file, the exact name of which is completely unimportant. This is a jar file and will be yours a module whose description will be inside it in module-info.class
. To create a runtime environment, you should run something like this command:
jlink --module-path . --add-modules tryout --launcher start=tryout/com.example.MainClass --output tryoutapp
Description of the parameters used:
--module-path .
tells you where to look for modules other than JDK modules. In this case, in the current directory .
.
--add-modules tryout
specifies which modules to include, except for the modules included by default from the JDK.
--launcher start=tryout/com.example.MainClass
says that you need to create startup scripts start
(UNIX Shell script) and start.bat
(Batch script) which will run the tryout
module by running the com.example.MainClass
class in that module. Specifying the class is optional, and in my case it was necessary because I was too lazy to specify it in MANIFEST.MF
inside the jar file.
--output tryoutapp
tells you in which directory to create a runtime environment. At the same time, if such a directory already exists and even if it is empty, there will be an error: "Error: directory already exists: tryoutapp".
Eventually you will get the directory tryoutapp
inside which will be everything you need to run your program (your module). However, you will not find your jar file there. Your module (and hence the class com.example.MainClass
), together with the other modules, will be located in the file tryoutapp/lib/modules
. In my case, the size of this file is 23 megabytes. The start scripts start
and start.bat
will be located in the tryoutapp/bin
directory.
You can get a more detailed description of the jlink
utility by running jlink --help
.
Jre 11 will not work. link from the image https://blogs.oracle.com/java-platform-group/oracle-jdk-releases-for-java-11-and-later
The above commentator stated that the Java 11 JRE does not exist.
The file has the name: jre-11-ea+8_windows-x64_bin.exe Actual size: 98.7 MB