1

I'm using maven, and I'm using vs code as my editor, and when I run mvn package, and then:

java -cp target/rationalclosure-1.0-SNAPSHOT-jar-with-dependencies.jar org.rationalclosure.App

in order to see if things are working, I get the following error (I believe due to some conflict in terms of which version of java is being used by my terminal and which is being used by maven):

I am using Java 11 in my terminal, and have since downloaded the jdk for java 12, but I'm not sure how to change the version of java used by my terminal to version 12. My questions are:

a.) would doing this solve the problem?
b.) how do I do this?

Note: I'm using wsl on the Ubuntu app on Windows as my terminal.

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/tweetyproject/logics/pl/syntax/Proposition has been compiled by a more recent version of the Java Runtime (class file version 56.0), this version of the Java Runtime only recognizes class file versions up to 55.0
        at java.base/java.lang.ClassLoader.defineClass1(Native Method)
        at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
        at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
        at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:800)
        at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:698)
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:621)
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:579)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
        at org.rationalclosure.App.main(App.java:11)

error I get when trying to run jar file

2
  • Update JAVA_HOME to point to Java 12, restart your terminal (to refresh environment variables), and then try again.
    – Slaw
    Aug 5, 2021 at 19:21
  • Has your question been resolved? May i know if you ever reached my answer? Aug 10, 2021 at 6:45

2 Answers 2

0

Open Command Palette and choose Java: Configure Java Runtime. Turn to Java Tooling Runtime, select java12 as JDK for Language Server:

enter image description here

Don't forget to reload Window to make this change effective.

0

Looks like you're trying to use a class compiled for Java 12 and you're using Java 11. So you can either upgrade your java version to 12, or you have to look at your dependencies and potentially get an older version. It really all depends on your constraints, but if you can, I recommend using the latest Java runtime.

For reference, here's the list of versions.

45 = Java 1.1
46 = Java 1.2
47 = Java 1.3
48 = Java 1.4
49 = Java 5
50 = Java 6
51 = Java 7
52 = Java 8
53 = Java 9
54 = Java 10
55 = Java 11
56 = Java 12
57 = Java 13

Not the answer you're looking for? Browse other questions tagged or ask your own question.