编译运行java代码的时候出现了如下错误
Error: A JNI error has occurred, please check your installation and try again
Exception in thread “main” java.lang.UnsupportedClassVersionError: ScannerTest has been compiled by a more recent version of the Java Runtime (class file version 58.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. r u n ( U n k n o w n S o u r c e ) a t j a v a . s e c u r i t y . A c c e s s C o n t r o l l e r . d o P r i v i l e g e d ( N a t i v e M e t h o d ) a t j a v a . n e t . U R L C l a s s L o a d e r . f i n d C l a s s ( U n k n o w n S o u r c e ) a t j a v a . l a n g . C l a s s L o a d e r . l o a d C l a s s ( U n k n o w n S o u r c e ) a t s u n . m i s c . L a u n c h e r 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 1.run(UnknownSource)atjava.security.AccessController.doPrivileged(NativeMethod)atjava.net.URLClassLoader.findClass(UnknownSource)atjava.lang.ClassLoader.loadClass(UnknownSource)atsun.misc.LauncherAppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
查了一下发现是由于javac和java版本不一致导致的,可以通过javac -version和java -version验证
解决方法:删除下面目录下的三个文件就正常啦
如果找不到这个文件路径,就去环境变量的path中找,最后面肯定是java\javapath