0

I started learning java and faced such a problem after using javac when I am using java, this code pops up. I searched the Internet and found many similar problems, but in the end none of this helped, and some were simply incomprehensible due to my poor English. The code and screenshot of the problem is attached below. Hope you can help solve the problem.

D:\Main\Projects\Java-Calculator>javac -version
javac 16.0.1

D:\Main\Projects\Java-Calculator>java -version
java version "1.8.0_291"
Java(TM) SE Runtime Environment (build 1.8.0_291-b10)
Java HotSpot(TM) 64-Bit Server VM (build 25.291-b10, mixed mode)

D:\Main\Projects\Java-Calculator>javac main.java

D:\Main\Projects\Java-Calculator>java main
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: main 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
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(Unknown Source)
        at java.security.SecureClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.defineClass(Unknown Source)
        at java.net.URLClassLoader.access$100(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)

This pops up in the console

  • Check your path - compiler (`javac`) comes from JDK install and there is likely also a JRE install it is finding (`java`). –  Jun 12 '21 at 13:44
  • Did you search for [java unsupportedclassversionerror](https://www.google.com/search?client=firefox-b-d&q=java+unsupportedclassversionerror)? Looks like you have more than one java version installed. Open [command prompt](https://en.wikipedia.org/wiki/Cmd.exe) window and enter: `where java`. This will give you location of file `java.exe`. Then enter: `where javac`. This will give you location of file: `javac.exe`. I suggest that you keep one java version and delete the others. – Abra Jun 12 '21 at 15:45

2 Answers2

0

As Far As I Know You Must Have A Java Path In Local Environment Variables As Well As In System Environment Variables (The Path of those might be different).You Just Have To Delete Java Path In System Environment Variables(Do It Carefully Don't Just Delete All Values).This Might Solve Your Problem. HAPPY CODING

Yeshwin Verma
  • 282
  • 3
  • 16
0

Thank you all for your answers, but so far none of your advice has helped to solve my problem. I will leave the question open if anyone wants to answer it. In the meantime, I solved this issue by using Eclipse temporarily

  • This simple article in my native language helped me solve my problem. Before the steps described in the article, I removed all components Java and rebooted the computer. Then I did the actions described in the article. Now everything works like a clock! https://tproger.ru/articles/start-writing-in-java/ – Fairushin-Fadis Jun 13 '21 at 05:32