-1

I have compiled .jar using OpenJDK 13 which cannot be run by most recent JRE (281). is it okay? (OpenJDK can run this .jar, but ordinary people won't use it)

This is the output:

$ ./java -jar HelloWorld.jar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorld 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
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown 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)
  • Are you sure your JRE is what you think it is? From your error message: "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". Your JRE is older than the JDK used for compiling. [u281](https://www.oracle.com/java/technologies/javase/8u281-relnotes.html) is Java 8 from March 2014. If you really want to support that old version, try the `--release` flag to `javac`. Or download an openjdk jre. – Robert Feb 14 '21 at 16:24
  • @mrRiseYT I consider myself one of _ordinary people_ and do use it. – Jonathan Rosenne Feb 14 '21 at 16:49

1 Answers1

0

It seems self-evident:

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

Why fight it?

If I were wanting to produce code for others to run, at the present time I'd still be using JDK 11 (=an LTS release from AdoptOpenJDK).

user15187356
  • 807
  • 3
  • 3