Answer the question
In order to leave comments, you need to log in
How to resolve the error "A JNI error has occurred, please check your installation and try again" when compiling a java program?
I am new to learning Java. Trying to run "hello world!" An example of what I'm running is below.
class hello {
public static void main(String args[]) {
System.out.println("Hello, world!");
}
}
***:~/Documents/JavaSampl$ javac hello.java
***:~/Documents/JavaSampl$ java hello
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: hello has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 53.0
at java.lang.ClassLoader.defineClass1([email protected]/Native Method)
at java.lang.ClassLoader.defineClass([email protected]/ClassLoader.java:939)
at java.security.SecureClassLoader.defineClass([email protected]/SecureClassLoader.java:152)
at jdk.internal.loader.BuiltinClassLoader.defineClass([email protected]/BuiltinClassLoader.java:553)
at jdk.internal.loader.BuiltinClassLoader.access$200([email protected]/BuiltinClassLoader.java:88)
at jdk.internal.loader.BuiltinClassLoader$3.run([email protected]/BuiltinClassLoader.java:466)
at jdk.internal.loader.BuiltinClassLoader$3.run([email protected]/BuiltinClassLoader.java:460)
at java.security.AccessController.doPrivileged([email protected]/Native Method)
at jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull([email protected]/BuiltinClassLoader.java:459)
at jdk.internal.loader.BuiltinClassLoader.loadClassOrNull([email protected]/BuiltinClassLoader.java:406)
at jdk.internal.loader.BuiltinClassLoader.loadClass([email protected]/BuiltinClassLoader.java:364)
at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass([email protected]/ClassLoaders.java:184)
at java.lang.ClassLoader.loadClass([email protected]/ClassLoader.java:419)
at sun.launcher.LauncherHelper.loadMainClass([email protected]/LauncherHelper.java:585)
at sun.launcher.LauncherHelper.checkAndLoadMain([email protected]/LauncherHelper.java:497)
Answer the question
In order to leave comments, you need to log in
In variable environments, you have the first on the list:
and at the end the path to jdk:
Therefore, when the operating system searches for java.exe , it first finds the one in ...\javapath and stops, and you need the one in ...jdk\bin . Therefore, you need to put ...\jdk\bin in environment variables before ...\javapath Like this:
PATH=C:\Program Files\jdk\bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\QuickTime\QTSystem\
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question