0

I tried to use cmd prompt to execute my java file but I got this error that says

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

but when I tried executing my java file on eclipse it works perfectly fine, its just that I want to try and run it to the command prompt to see if both ways works. Tried searching about the problem but most of the other problems is way back from long ago.

Pej
  • 17
  • 6
  • I think it is a version problem. Please check this. [https://stackoverflow.com/questions/22381202/a-jni-error-has-occurred-please-check-your-installation-and-try-again-in-eclips](https://stackoverflow.com/questions/22381202/a-jni-error-has-occurred-please-check-your-installation-and-try-again-in-eclips) – Deep Mar 25 '22 at 04:33
  • In my `javac -version` I get 16.0.2 while on my `java -version` I got 1.8.0_202` Doesn't seem right but I don't know why though. – Pej Mar 25 '22 at 04:46
  • 1
    Please check in Eclipse that the compile JDK version & target JDK version are matched or not. – Deep Mar 25 '22 at 05:35

1 Answers1

0

The problem was that my computer was confused as to what JRE to use. I have manually installed JDK and JRE 8 before.

So when I tried checking it through cmd.

javac -version is Java 16

while, java -version is Java 8

So, I uninstalled my Java 8 since I have installed JDK 16 and JRE version 16 on my eclipse which confuses my computer as to what version to use. That's pretty much it.

Pej
  • 17
  • 6