I have a simple Java program that consists of two .java files. It runs fine when executed from my IDE (IntelliJ). It also compiles (via the javac utility) just fine. However, when I attempt to run it from the Windows command prompt (using java <<myClassName>>) I get this error:
Exception in thread "main" java.lang.UnsupportedClassVersionError: JVMCFRE003 bad major version; class=RunExport, offset=6
at java.lang.ClassLoader.defineClassImpl(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:364)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:154)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:777)
at java.net.URLClassLoader.access$400(URLClassLoader.java:96)
at java.net.URLClassLoader$ClassFinder.run(URLClassLoader.java:1225)
at java.security.AccessController.doPrivileged(AccessController.java:366)
at java.net.URLClassLoader.findClass(URLClassLoader.java:660)
at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:942)
at java.lang.ClassLoader.loadClass(ClassLoader.java:851)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:827)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:494)
I have read various questions and proposed solutions for this error, but I have not been able to solve it. It appears that the version of Java used to compile the code is not recognized as being the same as that of the JRE in which I am running it. I am using jdk1.8.0_91. The javac.exe and java.exe files I am using are both in C:\Program Files\Java\jdk1.8.0_91\bin. This is also the path defined in my Windows PATH environment variable.
java -versionandjavac -versionto be sure which version is being executed. is RunExport one of the classes you created/compiled? The Exception should also state what the bad version number is, could help finding the correct java version to use.C:\Program Files\Java\jdk1.8.0_91\bin\java.exe <classname>