Unsupported major.minor version 51.0

java执行报错

“Exception in thread "main" java.lang.UnsupportedClassVersionError: xxx : Unsupported major.minor version 51.0”

原因是java编译和运行使用的jdk版本不一致:

$ whereis java

java: /usr/bin/java

$ ll /usr/bin/java*

lrwxrwxrwx 1 root root 22 Jul 10  2012 /usr/bin/java -> /etc/alternatives/java*
lrwxrwxrwx 1 root root 23 Jul 10  2012 /usr/bin/javac -> /etc/alternatives/javac*
lrwxrwxrwx 1 root root 25 Jul 10  2012 /usr/bin/javadoc -> /etc/alternatives/javadoc*
lrwxrwxrwx 1 root root 23 Jul 10  2012 /usr/bin/javah -> /etc/alternatives/javah*
lrwxrwxrwx 1 root root 23 Jul 10  2012 /usr/bin/javap -> /etc/alternatives/javap*
lrwxrwxrwx 1 root root 24 Jun 14 16:20 /usr/bin/javaws -> /etc/alternatives/javaws*

$ ll /etc/alternatives/java*

lrwxrwxrwx 1 root root 46 Jun 14 16:20 /etc/alternatives/java -> /usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java*
lrwxrwxrwx 1 root root 56 Jun 14 16:20 /etc/alternatives/java.1.gz -> /usr/lib/jvm/java-6-openjdk-amd64/jre/man/man1/java.1.gz
lrwxrwxrwx 1 root root 43 Jul 10  2012 /etc/alternatives/javac -> /usr/lib/jvm/java-7-openjdk-amd64/bin/javac*
lrwxrwxrwx 1 root root 53 Jul 10  2012 /etc/alternatives/javac.1.gz -> /usr/lib/jvm/java-7-openjdk-amd64/man/man1/javac.1.gz


在安装新的软件时系统环境被修改了,改回1.7。

sudo rm /etc/alternatives/java

sudo ln -s /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java /etc/alternatives/java


或装回JDK6,linux一些软件还不支持JDK7.

-----------------------------------------
通过rpm安装的jdk,java默认路径还原:

lrwxrwxrwx 1 root root 26 May 25 10:52 /usr/bin/java -> /usr/java/default/bin/java
lrwxrwxrwx 1 root root 27 May 25 10:52 /usr/bin/javac -> /usr/java/default/bin/javac
lrwxrwxrwx 1 root root 29 May 25 10:52 /usr/bin/javadoc -> /usr/java/default/bin/javadoc
lrwxrwxrwx 1 root root 28 May 25 10:52 /usr/bin/javaws -> /usr/java/default/bin/javaws

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值