0

I have a Java-8 application (including javafx) which I wrote a few years ago. It runs well under:

`   java version "1.8.0_291"
    Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
    Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)
`
B

ut on a different computer under:

    openjdk version "1.8.0_352"
    OpenJDK Runtime Environment (Temurin)(build 1.8.0_352-b08)
    OpenJDK 64-Bit Server VM (Temurin)(build 25.352-b08, mixed mode)

I get a JNI error:

Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.UnsupportedClassVersionError: javafx/application/Application 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

`   at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:756)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:473)
    at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:601)
`

The PATH looks OK: /usr/lib/jvm/jdk8u352-b08/bin:/bin:/opt/gradle/gradle-7.5.1/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

java and javac versions are identical: 1.8.0_352

I have explored any problem, I can think off, and have come out empty. Is it Oracle vs Openjdk?`

3
  • 1
    according to the exception message : your application was compiled by java 11 but you are trying to execute it with java 8. If you execute your application from IDE please verify you pointing to the right version of JDK. This link will give you a correspondence between Java version and bitcode version javaalmanac.io/bytecode/versions
    – JHDev
    Commented Jan 2, 2023 at 14:45
  • The above explanation does not apply. For the identical jar behaves differently on two desktops both running onLinux Mint 21 Cinnamon: it works with java version "1.8.0_291", it gives the above errors on openjdk version "1.8.0_352" (Temurin), i.e. both java 8. Commented Jan 3, 2023 at 11:04
  • 1
    Any way, The message of exception does not lie. Application has been compiled by a more recent version of the Java Runtime (class file version 55.0) ==>It is the version of bytecode generated by JDK 11. And like I said if you can run you an IDE, please check your JDK version. On desktop where the exception was thrown, try to find all installed Java (Jre)
    – JHDev
    Commented Jan 3, 2023 at 20:12

0

Browse other questions tagged or ask your own question.