转自:http://hi.baidu.com/piaokes/item/bbf79a33e85f744b3175a147
如果你遇到了 Unsupported major.minor version ,请认真看一下,说不定会有帮助。
我花两个小时总结的经验,你可能10分钟就得到了。 ^**^
一、错误现象:
当改变了jdk版本时,在编译java时,会遇到Unsupported major.minor version错误。
错误信息如下 :
Unsupported major.minor version 50.0
Unsupported major.minor version 49.0 (我在jdk1.4 和1.5切换时就遇到了这个错误)
Unsupported major.minor version 48.0
二、错误原因:
类似错误均属于Java版本问题,即JDK版本过低,只要选择相对应的JDK版本编译即可。
48,49,50是Java编译器内部的版本号:
Unsupported major.minor version 50.0 对应于 JDK1.6(JRE1.6)
Unsupported major.minor version 49.0 对应于 JDK1.5(JRE1.5)
Unsupported major.minor version 48.0 对应于 JDK1.4(JRE1.4)
三、出错过程:
我先描述一下我出错的过程,这样方便大家解决问题。
我用的是eclipse,在windows下调试的,是从jkd1.4升级到1.5后出现了该错误。
我是这么升级到1.5的:
(1)把在系统环境变量中把jdk的版本升级到了1.5,并在命令提示符下用 java -version 显示了一下jdk版本,是1.5的。
(2)在eclipse中 Window -> Preferences -> Java -> Compiler 然后在右侧窗口中,有个 Compiler compiance level: 就是指定jdk的版本,原来是1.4 ,现在选择5.0也就是jdk1.5。确定时弹出个对话框,提示改变了jdk版本,是否要立刻重新编译。点yes。eclipse会重新编译。【 图 1 】
(3)Project -> Properties -> Java Compiler 右侧窗口也有个 Compiler compiance level: 原来是1.4把它也改成5.0的。也会弹出对话框,同样选yes。【 图 2 】
(4)写了个Test类,执行是出现了错误:
java.lang.UnsupportedClassVersionError:
(Unsupported major.minor version 49.0)
(5)我重启eclipse问题依旧
至此,出错过程描述完毕。
四、解决办法:
仅仅按照网上说的设置JAVA_HOME 等方案是不能解决问题的。
下面是我的解决办法:
既然环境变量中和eclipse中都设置了jdk1.5的版本,为何还报错呢。
肯定是哪个地方还有设置。
(1)Project -> Properties ->Java Build Path 右侧窗口 -> Libraries 在列表里显示的竟然还是jdk1.4(是myEclipse5自带的。) 。
(2)将jdk1.4相关条目选中,然后点右侧按钮 Remove ,将jdk1.4删除。【 图 3 】
(3)点右侧 Add Library 弹出对话框,选中jdk1.5的条目,我这里显示的是 JRE System Library 然后点击next。 【 图 4 】
(4) 在第三步弹出的对话框上,激活 Alternate JRE 选项,并在下拉列表中,选择 jdk1.5 然后点Finish。【 图 5 】
(5)在第四步完成后,从Libraries 选项卡切换到 Order and Export 选项卡,并在jar列表中选中 JRE System Library[jdk1.5] 然后 点 ok完成设置。【 图 6 】
(6)如果你的Eclipse设置成了自动编译,应该就可以了,否则重新编译一下。
五、总结
根本原因还是开发环境中 jdk 环境变量的设置。
其实在我解决的过程中还有个细节给我带来了麻烦——就是我用了MyEclipse插件,它自带个jdk1.4 所以如果你也安装了myEclipse插件,最好别用myEclipse的jdk(它带很多额外包,调试过程没问题,结果发布后会有少jar包的可能),要用自己安装的。
我遇到的问题我解决了,不知你解决了没有。
相关推荐
Major version increments with each card supported. Minor version increments with each new feature. Sub-minor version increments when an existing feature changes.
We use 3 numbers for aria2 version: MAJOR.MINOR.PATCH. We will ship MINOR update on 15th of every month. We may skip a release if we have no changes since the last release. The feature and ...
M: Major version N: miNor version P: Patch number H: Hotfix number s: SVN number y: package year m: package month d: package day COEX_VER: Coext version _beta: beta driver
Later is supported when map2dbg.exe tool is placed in \Bin folder of EurekaLog installation (separate download is required) 5)....Added: Exception2HRESULT in EAppDLL to simplify developing DLLs with ...
- Windows 2000 / XP registry is now supported. Information is stored under HKEY_CLASSES_ROOT for 2000/XP systems. - New ban-list features allows you to ban certain users from using the next version ...
Windows 98 and ME are not supported in BurnInTest version 5.3 and above. Use a version of BurnInTest prior to 5.2 for compatibility with W98 and ME. Windows 95 and Windows NT =======================...
Mesa 18.0.4 implements the OpenGL 4.5 API, but the version reported by glGetString(GL_VERSION) or glGetIntegerv(GL_MAJOR_VERSION) / glGetIntegerv(GL_MINOR_VERSION) depends on the particular driver ...
Added ICQClientVer_Major, ICQClientVer_Minor constants in ICQWorks.pas[*] Some work-speed improvements[*] Improved info request/response procedures & events[*] Improved white pages (more compatible ...
has passed the usual votes to release that version. Only then is the final tarball packaged, removing all -rc# designations from the version number, and tagging the tree with the release number. ...
Major/Minor function Generic Parameters Information Input Output -------------------------------------------------------------------------- IRP_MJ_CREATE + + N/A IRP_MJ_CREATE_NAMED_PIPE + - - ...
NEWS for OpenSC -- History of user visible changes Complete change history is available online: ... New in 0.12.0; 2010-12-22 ...* This is an beta test version. Please be careful. Do not use in ...
As of version 2.1, use encodeRedirectURL(String url) instead encodeRedirectURL(String) - Method in class javax.servlet.http.HttpServletResponseWrapper The default behavior of this method is to ...
Minor changes to the scanning code for the filename of attachments.1.8.2- Fixed a bug with the filename of attachments (thanks to Taufer Pavel Ing.).- Added the function IsIPAddress from hou yg (the ...
Version 1.1 corrects a relatively minor bug that affected only certain installations. It also has been updated to change SIDs associated with the permission settings of file and printer shares. ...
- **DefineADC_AR_RELEASE_MAJOR_VERSION**: 定义了 AUTOSAR 重大版本号。 - **DefineADC_AR_RELEASE_MINOR_VERSION**: 定义了 AUTOSAR 次要版本号。 - **DefineADC_AR_RELEASE_REVISION_VERSION**: 定义了 ...
M: Major version N: miNor version P: Patch number s: SVN number y: package year m: package month d: package day 4. wpa_supplicant_hostapd/ 4.1 wpa_supplicant...
now supported, similar to the implementation of QuickCalc. Changes: + If background processing is enabled, during iteration the cursor is a combined arrow/hourglass to inform the user that he/...
Systems with 16 bit 'int' variables or segmented memory models are not supported. <br>Please report any modifications you had to apply in order to install the programs on your system to the ...
- Major configure/cpu rework allowing to enable/disable CPU options at runtime through .bochsrc (Stanislav) - Bugfixes for CPU emulation correctness and stability - Implemented X2APIC extensions ...