当我使用VSCode运行Java程序时,它总是显示一个错误,因为类文件的版本而导致无法识别已编译的类文件。
我已经检查了Mac的环境。 javac -version
和java -version
显示javac 1.8.0_181
和java 1.8.0_181
。
class Hello{
public static void main(String[] args) {
System.out.println("Hello World");
}
}
如果我运行代码,它将显示错误:
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 56.65535), this version of the Java Runtime only recognizes class file versions up to 52.0