2

enter image description here

I tried to make a package in JAR form. but when I tried it, it failed. how to fix this problem

java -jar out/artifacts/StrukturDasar_jar/StrukturDasar.jar

The Result was this :

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/dicoding/javafundamental/basic/Main has been compiled by a more recent version of the Java Runtime (class file vers
ion 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

My IDE and JDK:

IntelliJ IDEA 2019.1.3 (Community Edition)
Build #IC-191.7479.19, built on May 28, 2019
JRE: 1.8.0_202-release-1483-b58 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0

user207421
  • 305,947
  • 44
  • 307
  • 483
  • you will probably get better answers if posting the error message (easier to read) and stack trace as text instead of *just* the image – user85421 Aug 05 '19 at 04:48
  • Is this jar file StrukturDasar.jar you are using compatible with JDK 1.8, I think this jar file is in higher version of Java. – Sambit Aug 05 '19 at 05:00

1 Answers1

2

It happens due to JDK/JRE version mismatch - probably class compiled with higher version JDK, trying to be executed in low version JDK.

Java Runtime (class file vers ion 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

Either you have to sort the version mismatch or specify the target version during compilation command.

This helps you to achieve cross compilation.

https://docs.oracle.com/javase/7/docs/technotes/tools/windows/javac.html#crosscomp-example