0

This is not a duplicate! So I created a jar file and with manifest indicating the main-class. But when I try to run it with

java -jar app.jar

It prints in my CMD: "Error: A JNI error has occured, please check your instalation and try again. Exception in thread "main" java.lang.UnsupportedClassVersionError: Food has been compiled by a more recent version of the java run time (55) this version of the java runtime recognizes versions up to 52"

Weird thing is that I can compile and run java and class programs in CMD. But running JAR files, I can't.

I have jdk1.8.0_201 and jre1.8.0_201. Which I'm almost sure it's the latest. Atleast jre because when I open "configure java" program, and go to update tab and click "update now", it says: "you already have the latest java platform on this system. Shouldnt I keep the versions of jre and jdk equal?

Also I would like to have some clarification of the numbers of these jre and jdk. First in my ambient variables, all I have is jdk 1.8 and jre 1.8 just like above, so how can I tell me I have a more recent version?

So according to this post, How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version

if I have version 52 which is Java SE 8.0, why when install jdk, it says 1.8.0_201 and not 8.0? Tha's the same question of why microsoft skipped microsoft 9...

And yes I have java 11 (55) but it's not even in ambient variables.

And I searched for java SE 9,10,11,12 and 13 and they dont even exist. I cant look this JRE up. It's just so confusing.

Also when I just try to compile my program (which has HashMap, but I clarified the types at the end), it says

Food.java uses unchecked or unsafe operations Note: Recompile with -Xlint:unchecked for details https://pastebin.com/Vw2UerDG

and I think the problem is the put() method but it doesnt make sense to me what operation of put in unsafe. It just doesnt seem to be... Thanks

pedagogyfirst
  • 43
  • 1
  • 8

0 Answers0