错误:
java.lang.UnsupportedClassVersionError: Bad version number in .class file
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.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 java.lang.ClassLoader.loadClassInternal(Unknown Source)
Exception in thread "main"
程序:
public class ReadExcel {
public static void main(String args[]) {
String path = "D:\\test.xls";
System.out.println(path);
File file = new File(path);
InputStream is = null;
try {
is = new FileInputStream(file);
jxl.Workbook rwb = Workbook.getWorkbook(is);
Sheet st=rwb.getSheet(0);
Cell c00=st.getCell(0,0);
System.out.println(c00.getContents());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
------解决方案--------------------
你使用的java版本太低,使用java 5 或java 6版本。
java.lang.UnsupportedClassVersionError: Bad version number in .class file
jxl中的java版本高于你使用java版本
------解决方案--------------------
用最新的jdk,
清空一下项目的缓存,classes目录什么的
让项目再编译一遍试试
good luck
------解决方案--------------------
版本不兼容问题,不是代码问题