0

I'm taking a Java class on Pluralsite. The first exercise is, of course, an Hello World program. I'm using Intellij IDEA for my IDE. I write the program, from a template:

See code here

I run the code in the IDE. No problem. The next step is to run if from the command prompt. Per the class I put the location of the Java.exe in the JRE into my path. I reboot just to be sure. I open a command prompt as adminstrator in the directory where the program lives and start with "Java -version" and get

java version "1.8.0_241" Java(TM) SE Runtime Environment (build 1.8.0_241-b07) Java HotSpot(TM) 64-Bit Server VM (build 25.241-b07, mixed mode)

I type "Java Main" and I get:

I type "Java Main" and I get: 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 57.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)

Running: jdk-14 jre 1.8.0_241

I have uninstalled all things Java. Then reinstalled. I have uninstalled the IDE and reinstalled. Googled all over about this, no joy.

Another co worker is taking the course, same thing,

I will reach out to the person conducting this, but wanted to get this question out there in case he says "Works for me". Oh, Windows 10.

  • 1
    It means you compiled your java code with a JDK version which is greater than 8. Looks like your IDE is using JDK 14 – Abra Apr 03 '20 at 15:13
  • The class files were compiled for Java 13, you try to run it with Java 8. – Johannes Kuhn Apr 03 '20 at 15:14
  • 1
    Open Project Structure Dialog in Idea (File/Project Structure); press "New" at "Project SDK" configuration, choose your Java 8 JDK directory and ensure that this JDK 8 is set as a Project SDK. Rebuild your project and try again. – vbezhenar Apr 03 '20 at 15:35
  • If you select item _About_ under the _Help_ menu, it should display the JDK version that comes bundled with Intellij. – Abra Apr 03 '20 at 15:38

0 Answers0