Reputation: 11
I wrote a 'Helloworld.java' file by using the notepad. I compiled on cmd by writing 'javac Helloworld.java', I got 'Helloworld.class' file in the same dir.
I wrote 'java Helloworld' to launch it, and A JNI error has occurred.
I checked my java version, and could not find the cause. How do I solve the problem?
C:\Users\chan5\OneDrive\문서\Java_tutorials>java -version java version "1.8.0_201" Java(TM) SE Runtime Environment (build 1.8.0_201-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode)
I added my java-bin's path to the path list of the system.
below is my cmd screen:
C:\Users\chan5\OneDrive\문서\Java_tutorials>dir/w C 드라이브의 볼륨에는 이름이 없습니다. 볼륨 일련 번호: 68B8-C9E4
C:\Users\chan5\OneDrive\문서\Java_tutorials 디렉터리
[.] [..] Helloworld.class Helloworld.java 2개 파일 542 바이트 2개 디렉터리 120,717,078,528 바이트 남음
C:\Users\chan5\OneDrive\문서\Java_tutorials>java Helloworld
Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.UnsupportedClassVersionError:
Helloworld has been compiled by a more recent version of the Java Runtime (class file version 56.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)
C:\Users\chan5\OneDrive\문서\Java_tutorials>
Upvotes: 1
Views: 276
Reputation: 4699
Note this line:
Helloworld has been compiled by a more recent version of the Java Runtime (class file version 56.0)
It looks like you've compiled with Java 12 but you are trying to run with Java 8.
Upvotes: 1