一、异常描述
在centos系统下安装jdk1.7环境,进行配置安装apache-ant-1.10.5-bin.zip后,运行ant -version后,报”Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/tools/ant/launch/Launcher : Unsupported major.minor version 52.0“,详情日志如下>>
[root@centos6 ant]# ant -version@b@Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/tools/ant/launch/Launcher : Unsupported major.minor version 52.0@b@ at java.lang.ClassLoader.defineClass1(Native Method)@b@ at java.lang.ClassLoader.defineClass(ClassLoader.java:800)@b@ at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)@b@ at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)@b@ at java.net.URLClassLoader.access$100(URLClassLoader.java:71)@b@ at java.net.URLClassLoader$1.run(URLClassLoader.java:361)@b@ at java.net.URLClassLoader$1.run(URLClassLoader.java:355)@b@ at java.security.AccessController.doPrivileged(Native Method)@b@ at java.net.URLClassLoader.findClass(URLClassLoader.java:354)@b@ at java.lang.ClassLoader.loadClass(ClassLoader.java:425)@b@ at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)@b@ at java.lang.ClassLoader.loadClass(ClassLoader.java:358)@b@ at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
环境配置如下
[root@centos6 app]# cat /etc/profile@b@...@b@export JAVA_HOME=/home/app/jdk7@b@export JAVA_BIN=$JAVA_HOME/bin@b@export JRE_HOME=$JAVA_HOME/jre@b@export ANT_HOME=/home/app/ant @b@@b@CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib:$ANT_HOME/lib@b@@b@PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin:$ANT_HOME/bin
二、解决方法
主要因jdk1.7的版本无法匹配ant高版本1.10.5,重写下载对于版本apache-ant-1.7.1-bin.tar.gz进行安装配置,问题即可解决了
[root@centos6 app]# ant -version@b@Apache Ant version 1.7.1 compiled on June 27 2008