Phantom11
Phantom11

Reputation: 3

Running Java -jar command, and get a version error

When I run my Java -jar command, I get this error. I have tried to change my Intellij JDK to 11, but it gave the exact same error.

(both project structure SDK/language level is 17 currently. when I change the jdk from 11-17, it does not change the java --version output.)

Error: LinkageError occurred while loading main class KioskApp
    java.lang.UnsupportedClassVersionError: KioskApp 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 55.0

my Intellij is running on openJDK17(17.0.2) but from my command line(where I am running the Java -jar command from) my java --version shows

OpenJDK Runtime Environment (build 11.0.14+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.14+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)

Upvotes: 0

Views: 255

Answers (1)

Onke
Onke

Reputation: 113

So there are two java versions here. One is the default java version for your system which is java 11. The other one is the default java version on your intellij which is 17. So if you compile your jar with intellij and then try to run that jar on your terminal, it will spit out that error since the java version for run and compilation don't match.

When you do stuff on your terminal/console, it will use the systems default java version. Pick one place for both compilation and run. Its either you make your IntelliJ java version match with the systems java version or you do both you compilation and jar run on intelliJ

Upvotes: 1

Related Questions