Skip to content
Advertisement

Java appears to be outdated when using java -jar command

I have recently been writing some Java programs on my Windows computer. I have been trying to use java -jar to run compiled jars in order to see errors more clearly, but when I try to do this, I get the following error:

JavaScript

This obviously means that my java version is outdated. However, when I took a look at the Java Updater, it shows that I am running the latest version. Running java -version shows this:

JavaScript

So why is Command Prompt using an older version, and how do I change it? Thank you for your help.

Advertisement

Answer

This error clearly indicates that you try to run a .jar file built with JDK 13 (major version 57) on a JRE/JDK 8 (major version 52) which is provided in PATH setting and thus invoked when running java -jar / java -version commands.

If you have JDK 13 installed on your machine, you need to check environment variable PATH and/or JAVA_HOME:

JavaScript

If PATH refers JRE/JDK 8, you may create another variable and update PATH (copy non-java paths):

JavaScript

If you do not have JDK 13 on your machine, to resolve this issue you should rebuild the .jar file to make it compatible with JDK 8 providing that the code is not using any features from the newer versions.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement