wobushixiaobailian
我不是小白脸
2018-11-06 12:06
采纳率: 20%
浏览 6.2k
已采纳

编译jdk1.7时发生错误:Unsupported major.minor version 52.0

今天试着编译jdk1.7。make sanity都check passed了,可是在make时,就发生这个错误:

make[2]: Entering directory '/home/fengli/Downloads/MyOpenJdk7/langtools/make'
JAVA_HOME=/usr/lib/jdk1.6.0_32 ANT_OPTS=-Djava.io.tmpdir='/home/fengli/Downloads/MyOpenJdk7/build/langtools/build/ant-tmp' /usr/lib/apache-ant-1.10.3/bin/ant -Djdk.version=1.7.0 -Dfull.version='1.7.0-internal-root_2018_11_06_19_55-b00' -Dmilestone=internal -Dbuild.number=b00 -Djavac.target=7 -Djavac.source=7 -Dboot.java.home=/usr/lib/jdk1.6.0_32 -Dimport.jdk=/home/fengli/Downloads/MyOpenJdk7/jdk -Dbuild.dir=/home/fengli/Downloads/MyOpenJdk7/build/langtools/build -Ddist.dir=/home/fengli/Downloads/MyOpenJdk7/build/langtools/dist build
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/tools/ant/launch/Launcher : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
at java.net.URLClassLoader$1.run(URLClassLoader.java:197)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.apache.tools.ant.launch.Launcher. Program will exit.
Makefile:201: recipe for target 'build' failed
make[2]: *** [build] Error 1
make[2]: Leaving directory '/home/fengli/Downloads/MyOpenJdk7/langtools/make'
make/langtools-rules.gmk:37: recipe for target 'langtools-build' failed
make[1]: *** [langtools-build] Error 2
make[1]: Leaving directory '/home/fengli/Downloads/MyOpenJdk7'
Makefile:244: recipe for target 'build_product_image' failed
make: *** [build_product_image] Error 2

我/etc/profile是这样的:

/etc/profile: system-wide .profile file for the Bourne shell (sh(1))

and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "$PS1" ]; then
if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
# The file bash.bashrc already sets the default PS1.
# PS1='\h:\w\$ '
if [ -f /etc/bash.bashrc ]; then
. /etc/bash.bashrc
fi
else
if [ "id -u" -eq 0 ]; then
PS1='# '
else
PS1='$ '
fi
fi
fi

if [ -d /etc/profile.d ]; then
for i in /etc/profile.d/*.sh; do
if [ -r $i ]; then
. $i
fi
done
unset i
fi

jdk1.8

#export JAVA_HOME=/usr/lib/jdk1.8.0_191
#export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
#export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH

jdk1.7

#export JAVA_HOME=/usr/lib/jdk1.7.0_80
#export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
#export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH

jdk1.6

export JAVA_HOME=/usr/lib/jdk1.6.0_32
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH

#set Ant enviroment
export ANT_HOME=/usr/lib/apache-ant-1.10.3
export PATH=$PATH:$ANT_HOME/bin

for jdk7 compile

export LANG=C
#BootStrap-JDK
export ALT_BOOTDIR=/usr/lib/jdk1.6.0_32
#OracleJDK
export ALT_JDK_IMPORT_PATH=/usr/lib/jdk1.6.0_32
#
export ALLOW_DOWNLOADS=true
#the same with you cup cores
export HOTSPOT_BUILD_JOBS=2
export ALT_PARALLEL_COMPILE_JOBS=2
#
export USE_PRECOMPILED_HEADER=true
#
export BUILD_LANGTOOLS=true
export BUILD_JAXWS=false
#export BUILD_JAXP=false
#export BUILD_CORBA=false
export BUILD_HOTSPOT=true

export BUILD_JDK=true

export SKIP_COMPARE_IMAGES=true
#
BUILD_DEPLOY=false
#
BUILD_INSTALL=false
#
export ALT_OUTPUTDIR=/home/fengli/Downloads/MyOpenJdk7/build
#
unset JAVA_HOME
unset CLASSPATH
#
make 2>&1 | tee $ALT_OUTPUTDIR/build.log

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • wobushixiaobailian
    我不是小白脸 2018-11-06 13:25
    已采纳

    我已经知道了。还是谢谢了哈!!!。原因是apache-ant-1.10.3需要jdk8支持,我吧它改成apache-ant-1.7.1就行了(-_-)

    点赞 评论
  • hu582205
    胡易卿 2018-11-06 12:26

    直译过来意思是:不支持version52.0,其中version 52.0是魔码的其中一个版本,他对应的是jdk1.8

    所以异议过来就是:不支持jdk1.8

    点赞 评论
  • csdn_conda
    打怪的小兵 2018-11-06 13:09

    如楼上所说,不支持 52.0, 也就是jdk1。8,
    你可以java 切换到1.7版本,
    sudo update-alternatives --config java
    选择1.7的项

    点赞 评论

相关推荐