0

I've recently created a .jar for a program I wrote using JDK 14.0.1 and I'm trying to run it, but I keep getting an error message saying that the .jar was compiled in file version 55, and my current Java Runtime environment "only recognizes class file versions up to 52.0"

I've tried updating Java through the control panel and I've updated the JAVA_HOME and system paths to 14.0.1, but even after restarting my computer, my java version and Java SE Runtime Environment versions are still on 1.8.

(Please ignore username, I made it up in middle school)

C:\Users\Dudenugget123>java -version
java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, mixed mode)

C:\Users\Dudenugget123>javac -version
javac 14.0.1

C:\Users\Dudenugget123\Desktop\BlueJ Programs\ThreeCombos>java -jar ThreeCombos.jar
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: ThreeCombos 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(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)
1
  • you can also set path in current shell, windows : set PATH=%JAVA_HOME%/bin; Linux: export PATH=$JAVA_HOME/bin Commented May 27, 2020 at 20:18

1 Answer 1

1

Check your %PATH% environment variable, it probably contains the path to your old JRE. Remove that, and insert the path to your new JRE.

%PATH% defines where your operating system looks when you try to start a program without specifying the full path. %JAVA_HOME% is used by a bunch of Java-specific tools like ant, but it has no meaning to your operating system or your command prompt.

Sign up to request clarification or add additional context in comments.

3 Comments

I thought I already did that. My "Path" System variable has 'C:\Program Files\Java\jdk-14.0.1\bin'
Well, check again. If both the old and the new JRE are in your %PATH%, I think the one that is first in the list will take precedence.
Sweet! I moved the jdk-14.0.1 to the top of the list and the java version changed. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.