0

So as the title says, I'm trying to run my code through the terminal and the following error is coming up:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: FizzBuzz has been compiled by a more recent v
ersion of the Java Runtime (class file version 58.0), this version of the Java Runtime only recognizes class fil
e 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) 

I've tried following tutorials and guides to solve this but they haven't worked. I've set the JDK and JSE to be Java 15 as you can see in the images below and nothing is changing.

JRE JDK

I have only just installed IntelliJ today, and I am very new to this all so any help would need to be as simple and specific as possible.

Scott Dunn
  • 321
  • 1
  • 3
  • 5
  • 1
    run java -version and javac -version to see your compiled and runned java version – Sox - Nov 04 '20 at 18:45
  • I ran java -version and it said 1.8.0_191 and tried to run javac -version and it said 'javac' is not recognized as an internal or external command, operable program or batch file. – Scott Dunn Nov 04 '20 at 19:22
  • https://stackoverflow.com/questions/7709041/javac-is-not-recognized-as-an-internal-or-external-command-operable-program-or Take a look at carlos c. 's answer it is pretty detailled – Sox - Nov 04 '20 at 19:26

1 Answers1

0

When you run from the terminal, the Java version that is available on your PATH determines which JRE is invoking the program - this might be different than the JRE used by the IDE. Either run directly from the IDE, or change the PATH to include the right Java version (if there are multiple versions defined there, remove the other ones). You can either change it in the context of the terminal, or system-wide (in which case you'll have to consider compatibility with other programs using Java).

Itaypk
  • 1,103
  • 10
  • 25