.class中错误版本号的异常解释?

时间:2012-03-21 13:14:44

标签: java exception exception-handling

任何人都可以解释此异常并提供解决方案吗?

Exception in thread "AWT-EventQueue-1" java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at de.az.j2eeoe.util.configtoolscanners.control.ftp.Ftp.uploadFileToServerViaJftp(Ftp.java:209)
at de.az.j2eeoe.util.configtoolscanners.control.UploadAction.actionPerformed(UploadAction.java:56)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.java:5517)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3129)
at java.awt.Component.processEvent(Component.java:5282)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3984)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3819)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1791)
at java.awt.Component.dispatchEvent(Component.java:3819)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at de.az.webutil.gui.WebEventQueue.dispatchEvent(WebEventQueue.java:34)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
    [21/03/2012 13:50:51:086] *** Before pollWebLogic Server, request #2
    [21/03/2012 13:50:51:090] *** After pollWebLogic Server, request #2 (duration: 4ms)
    [21/03/2012 14:00:51:127] *** Before pollWebLogic Server, request #3
    [21/03/2012 14:00:51:129] *** After pollWebLogic Server, request #3 (duration: 2ms)

2 个答案:

答案 0 :(得分:0)

该类可能已经编译为更新的Java版本而不是您尝试运行它的版本。在第一次安装JRE然后是JDK之后,我自己遇到过这个问题几次,这导致PATH环境变量得到一个值,导致java解析为JRE安装目录中的可执行文件,而javac已解析为JDK安装目录中的那个。

答案 1 :(得分:0)

如果编译该类的目标JRE版本高于正在运行的JRE版本,则抛出此异常。如果您为JRE 1.6编译但是在JRE 1.5上运行它,则会出现此错误。

解决方案是更新您的JRE,或使用正确的目标重新编译代码。