Y:>javac Demo01Const.java
Y:>java Demo01Const
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: Demo01Const has been compiled by a more recent version of the Java Runtime (class file version 53.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)
請問各位,我執行程式出現這樣該如何處理
先比較一下這兩個版本是否一致
java -version
javac -version
依據錯誤訊息來看
javac 的版本(53.0)應該大於 java 的版本(52.0)
也就是 javac 比較新
接著你就會需要
把兩個版本一致的方法
public class HelloJava{
public static void main(String args[]){
System.out.println("HelloJava");
}//方法:main() 定義區塊結束
}//類別:HelloJAVA定義區塊結束
一般的JAVA HELLO JAVA程式如上
先別急著COPY到你的IDE,先確認開檔的環境有沒有設錯,依照書上的寫法再確認一次.........
JAVA很嚴格,package,class 錯一個步驟,一個字就都執行不了......