Search code examples

What happened to the JRE?

So, I've coded a Java Swing application in my Debian PC, and compiled it with IntelliJ into a JAR file. However, while it runs normally on the system it was coded on, it causes a Java Exception when running on other Windows machines. When I run it on the command line to show more details about the exception, this is the output:

-jar out.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: Main has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at Source)
        at Source)
        at$100(Unknown Source)
        at$ Source)
        at$ Source)
        at Method)
        at Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

Bare in mind that this happened even with a completely updated JRE.

Obviously, after encountering this issue, i did some research about it, and it came to me that i had to download the most recent JDK into my Windows system, as apparently Oracle stopped distributing JREs, so programs compiled in more recent versions of the JDK don't run in computers that don't have a JDK installed. And this seemed to work - after installing said JDK, the program ran normally.

However, this still is an issue; not for me directly, but for those that may eventually use my software.

Let's suppose, for example, that I make a program to help a friend of mine with something in his PC, written in Java. As he is not a developer, he doesn't have any JDK installed on his PC, only a JRE that he may have previously installed. So, in order to make it so that he can run my program, i would have to make him install the most recent JDK into his computer, as everyone that would someday use a program that I made would have to install it as well, which doesn't seem very practical for me.

So, in conclusion, this entire situation just made me very confused, especially as I can't find anything in the internet that actually clearly explains what happened with the JRE - and that's what im trying to understand better - What actually happend to the JRE? If it actually got discontinued, does that mean that everyone that wants to use a recently programmed java program have to install the JDK? Or is it just something that I am missing? Perhaps compiling in Linux instead of windows has something to do with it?

Also, I found some people saying that a fix to this issue would be to just downgrade my JDK to a version that the "most recent" JRE actually supports, but I just feel like that doesn't quite make sense, as I would be missing on a lot of new Java features, kind of defeating the purpose of keeping the Java language updated.

So, can someone clarify all of this for me? Thanks in advance!


  • tl;dr

    • Oracle is but one vendor of implementations of the Java specs.
    • Some JDK vendors do offer a JRE edition.


    Oracle is the owner of the Java™ brand, the publisher of the Java specifications, and leader of the Java community.

    So required reading is this Oracle white paper, Java Client Roadmap Update of 2020-05, and related blog post. This marks Oracle’s dramatic shift from their Java Everywhere strategy. Oracle no longer pursues the bundling of a JRE with every major operating system as had been done in the past.

    Instead, Oracle expects desktop apps to be shipped with a JVM contained internally. To this end they created the Java Platform Module System (JPMS), and produced the jlink and jpackage tools. If your app is modularized, you can bundle a JVM slimmed down to include only the parts your particular app actually uses.

    So you can see from this point of view, the need for a JRE evaporates. A JRE is just a JDK without build/compilation-related tools. If apps include a JVM, and users are no longer expected to be installing Java onto their desktop machines, then a JRE is unnecessary.

    As I recall, you are correct: Oracle no longer distributes JRE products, at least not to the public. But you should check with their sales force to be certain. But Oracle is not your only source for an implementation of the Java specs.

    You should read Java Is Still Free 3.0.0 (Oct 2021), by pillars of the Java community.

    Oracle is only one of several vendors providing JDK products. These vendors include:

    • Azul Systems
    • Adoptium by Eclipse Foundation
    • IBM
    • Red Hat
    • BellSoft
    • Oracle
    • Amazon
    • Microsoft
    • SAP
    • … and more.

    All of their products are throughly tested. Most are based largely, if not entirely, on the OpenJDK codebase implementation of the Java specs.

    Some of these vendors choose to provide a JRE edition of their products. Such products may be useful in controlled environments such as the enterprise and education where an IT admin department may want to deploy and maintain a JRE across their users’ machines.

    If you decide you really want a JRE, examine the offerings of all the JDK vendors. Pay attention to the terms of their license.

    You can bundle a JVM with your app by way of the jlink tool. To make your app “double-clickable” for launching like conventional apps, use the jpackage tool.

    Tip: For JavaFX apps, you may be interested in a JDK/JRE that bundles the OpenJFX implementation libraries. At least two vendors offer such editions of their JDK/JRE products:

    • Azul Systems
    • BellSoft