解决Unsupported major.minor version 49.0问题(转)

本文介绍了Java虚拟机(JVM)版本与Java类文件版本之间的兼容性问题。不同版本的JVM如何运行不同版本的Java类文件,以及为何某些类文件无法在旧版JVM上运行的原因。此外还探讨了Sun公司在确保JVM版本兼容性方面所采取的措施。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

原地址 

解决办法:
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.

HTTP Status 500 - type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception org.apache.jasper.JasperException: An exception occurred processing JSP page /inputCheck.jsp at line 32 29: String name=request.getParameter("studentName"); 30: String gender=request.getParameter("gender"); 31: int age=Integer.parseInt(request.getParameter("age")); 32: Class.forName("com.mysql.jdbc.Driver"); 33: String url="jdbc:mysql://localhost:3306/xuesheng?useUnicode=true&characterEncoding=gbk"; 34: Connection con=DriverManager.getConnection(url,"root","1234"); 35: // out.print("鏁版嵁搴撹繛鎺ユ垚鍔燂紒"); Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:524) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:417) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) root cause javax.servlet.ServletException: java.lang.UnsupportedClassVersionError: com/mysql/jdbc/Driver : Unsupported major.minor version 52.0 org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779) org.apache.jsp.inputCheck_jsp._jspService(inputCheck_jsp.java:157) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266) javax.servlet.http.HttpServlet.service(HttpServlet.java:803) root cause java.lang.UnsupportedClassVersionError: com/mysql/jdbc/Driver : Unsupported major.minor ve
最新发布
06-17
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值