Unsupported major.minor version 49.0

 

 

錯誤信息:

Exception in thread "main" java.lang.UnsupportedClassVersionError: com/ccit/neg/
udp/UDPServer (Unsupported major.minor version 49.0)
        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:537)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:12
3)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)

解決辦法:
1. java -version 看顯示的JDK版本
2.path查看所有的路徑設置(可以在所有路徑中使用java關鍵詞進行搜索),如:本人IBM筆記本,自動安裝jdk1.4,c:/Windows/system32下有java.exe等命令。在控制面板:刪除和添加程序中找到並刪除即可。
3. 查看註冊表,修改註冊表HKEY_LOCAL_MACHINE/SOFTWARE/JavaSoft下的關於1.4的jre和jvm的路徑信息改爲1.5的jdk的即可。

英文介紹(轉載):
Each java class has a version stamp, older versions have lower numbers. The JVM is backward compatible, so older classes also run in a newer JVM. Version ranges are as follows:

Java 1.1 platform: 45.3-45.65535
Java 1.2 platform: 45.3-46.0
Java 1.3 platform: 45.3-47.0
Java 1.4 platform: 45.3-48.0

Java 5 class files are stamped with 49.0, and the JVM is also backward compatible. So, a 1.3 class file will run in a 1.5 JVM, but not the other way round. That's the reason for the original problem. None of us would be able to run Struts in an 1.4 or 1.5 JVM if it were otherwise, as the binaries are 1.3 versions, IIRC. Apart from that, Sun has been very careful when it comes to JVM version compatibility, much more than in other parts,
Serialization would be a prominent example here. IIRC there were no changes to the class format in 1.2 and 1.3, possibly including 1.1 even. The changes made in 1.5 were mostly required by the extended type system (Generics | 'type erasure'). Another aspect of backward compatibility is the usage of features in the Foundation Classes; this lib has steadily grown over the years. If a class files has dependencies on other
classes only available in a more recent version, trying to do so will end up in a ClassNotFound exception, but thats just what is to be expected. An example for that would be Tomcat 5.5: normally, it requires Java 5, but you can install a compatibility package that provides the missing features and makes it run in a 1.4 setup.
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章