Centos系统下载大全 | Redhat系统下载大全 | Windows2012系统下载大全 | Windows2008系统下载大全| CMS教程 | 网站地图 51运维网-专注Linux/Unix系统安全运维!
当前位置:51运维网 > 教程 > Linux网络管理 > 正文

CentOS下编译安装OpenJDK6过程

时间:2016-06-26 23:58 来源:网络整理 作者:linux系统 阅读:

CentOS编译安装OpenJDK6过程

时间:2015-09-08 01:28来源:blog.csdn.net 作者:萧易客 举报 点击:次

由于初次手动编译OpenJDK6, 踩的坑还不少, 各种依赖不足以及奇葩的事情, 特此整理记录, 给后人防坑. 
编译环境信息:

[root.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64 x86_64 x86_64 GNU/Linux [root@dev-52 openjdk6]# arch && cat /etc/centos-release x86_64 CentOS release 6.2 (Final) [root@dev-52 openjdk6]# nproc 8 [root@dev-52 ~]# free -m total used free shared buffers cached -

OpenJDK版本: openjdk-6-src-b27-26_oct_2012.tar.gz  下载地址: https://java.net/projects/openjdk6/downloads/

[root@dev-52 ~]# mkdir openjdk6 && tar xf openjdk-6-src-b27-26_oct_2012.tar.gz -C openjdk6 [root@dev-52 ~]# ll openjdk6 總計 320 -rw-rw-r-- 1 uucp 143 1503 2012-10-27 02:21 ASSEMBLY_EXCEPTION drwxrwxr-x -10-27 02:28 corba -rw-rw-r-- 1 uucp 143 1373 2012-10-27 02:21 get_source.sh drwxrwxr-x -10-27 02:28 hotspot drwxrwxr-x -10-27 02:28 jaxp drwxrwxr-x -10-27 02:28 jaxws drwxrwxr-x -10-27 02:28 jdk drwxrwxr-x -10-27 02:29 langtools -rw-rw-r-- 1 uucp 143 19263 2012-10-27 02:21 LICENSE drwxrwxr-x -10-27 02:28 make -rw-rw-r-- 1 uucp 143 14485 2012-10-27 02:21 Makefile -rw-rw-r-- 1 uucp 143 1803 2012-10-27 02:21 README -rw-rw-r-- 1 uucp 143 101427 2012-10-27 02:21 README-builds.html -rw-rw-r-- 1 uucp 143 4807 2012-10-27 02:21 ReleaseProcess.html drwxrwxr-x -10-27 02:28 test -rw-rw-r-- 1 uucp 143 127498 2012-10-27 02:21 THIRD_PARTY_README -rw-rw-r-- 1 uucp 143 2113 2012-10-27 02:21 TRADEMARK # 安装依赖, 编译OpenJDK需要先安装一个JDK, 无论是OpenJDK还是Oracle JDK都行 [root@dev-52 ~]# yum install java-1.6.0-openjdk alsa-lib-devel gawk binutils libpng-devel freetype-devel openmotif openmotif-devel cups-devel ant libXtst-devel -y # 将编译参数全部写到一个脚本中 [root@dev-52 openjdk6]# cd openjdk6 [root@dev-52 openjdk6]# vim build.sh #!/bin/bash export OPENJDK_HOME=/root/openjdk6 # 解压的源码包位置 export LANG=C export ALT_BOOTDIR=/usr/lib/jvm/java-1.6.0-openjdk.x86_64 # 机器上现有的JDK位置, 下面一样 export ALT_JDK_IMPORT_PATH=/usr/lib/jvm/java-1.6.0-openjdk.x86_64 export ALT_OUTPUTDIR=$OPENJDK_HOME/build # 编译输出目录 export ALLOW_DOWNLOADS=true export HOTSPOT_BUILD_JOBS=8 # 编译线程数, 与CPU核数一致即可 export ALT_PARALLEL_COMPILE_JOBS=8 export DEV_ONLY=true export USE_PRECOMPILED_HEADER=true export BUILD_LANGTOOLS=true export BUILD_JAXP=false # 下面三个组件编译时需要从网络上下载相关依赖包, 耗时较长且对于作者没有任何用处就取消编译了 export BUILD_JAXWS=false export BUILD_CORBA=false export BUILD_HOTSPOT=true export BUILD_JDK=true export BUILD_DEPLOY=false # 取消构建部署和安装包 export BUILD_INSTALL=false unset JAVA_HOME unset CLASSPATH make sanity # 验证 [root@dev-52 openjdk6]# chmod +x build.sh [root@dev-52 openjdk6]# ./build.sh # 由于输出内容过长占用篇幅较大就不完全贴出来了, 尾部的输出如下: WARNING: You are not building the JAXP sources. The jaxp files will be obtained ALT_JDK_IMPORT_PATH. WARNING: You are not building the JAXWS sources. The jaxws files will be obtained ALT_JDK_IMPORT_PATH. WARNING: You are not building the CORBA sources. The corba files will be obtained ALT_JDK_IMPORT_PATH. WARNING: Your build environment has the variable DEV_ONLY defined. This will result in a development-only build of the JDK, lacking the documentation build and installation bundles. Sanity check passed. # 检查通过 # 修改build.sh的最后一行为如下, 然后在此执行脚本: make sanity && make 2>&1 | tee $ALT_OUTPUTDIR/build.log [root@dev-52 openjdk6]# ./build.sh # 自2015年开始一般会出现如下异常 /opt/jdk1.6.0_31/bin/java -Xmx896m -Xms128m -XX:PermSize=32m -XX:MaxPermSize=160m -jar /root/openjdk6/build/btjars/generatecurrencydata.jar -o /root/openjdk6/build/lib/currency.data.temp \ < ../../../src/share/classes/java/util/CurrencyData.properties Error: time is more than 10 years from present: 1120165200000 java.lang.RuntimeException: build.tools.generatecurrencydata.GenerateCurrencyData.makeSpecialCaseEntry(GenerateCurrencyData.java:285) at build.tools.generatecurrencydata.GenerateCurrencyData.buildMainAndSpecialCaseTables(GenerateCurrencyData.java:225) at build.tools.generatecurrencydata.GenerateCurrencyData.main(GenerateCurrencyData.java:154) make[cd linux_amd64_compiler2/product && ./test_gamma java full version "1.6.0_36-b36" ./gamma: relocation .x86_64/jre/lib/amd64/libjava.so: symbol JVM_FindClassFromCaller, libjvm.so [root@dev-52 openjdk6]# vim `find . -name 'CurrencyData.properties'` # 编译完成后末尾输出如下, 也可检查程序的退出码: >>>Making sec-files-win @ Mon Sep 7 15:06:20 CST 2015 ... >>>Making jgss-files @ Mon Sep 7 15:06:20 CST 2015 ... >>>Finished making images @ Mon Sep 7 15:06:20 CST 2015 ... make[2]: Leaving directory `/root/openjdk6/jdk/make' make[1]: Leaving directory `/root/openjdk6' Control linux amd64 :06 Control linux amd64 :06 Control linux amd64 :06 [root@dev-[root@dev-52 openjdk6]# cd build/j2sdk-image/bin [root@dev-52 j2sdk-image]# ls ASSEMBLY_EXCEPTION bin demo include jre lib LICENSE man sample src.zip THIRD_PARTY_README [root@dev-52 bin]# ./java -version openjdk version "1.6.0-internal" OpenJDK Runtime Environment (build 1.6.0-internal-root_07_sep_2015_14_49-b00) OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

到此整个编译过程就结束了, 当然第一次编译肯定不会这么顺利的完成, 操作时需要细心, 当然编译OpenJDK7也是大同小异, 在debain平台下依赖包的名字可能会有差异, 这需要注意一下.  OK, 对JVM感兴趣的同学赶紧亲自动手试一下吧.

参考资料
  • 《深入理解Java虚拟机:JVM高级特性与最佳实践》 作者: 周志明
  • ------分隔线----------------------------

  • 上一篇:CentOS 6.5 安装haproxy
  • 下一篇:centos6.5安装cmake
  • 【linux教程】 【linux操作系统】 【linux命令大全】

    感谢您对【51运维网 http://www.51ou.com/】的支持,我们为您免费提供《CentOS下编译安装OpenJDK6过程》技术文章,《CentOS下编译安装OpenJDK6过程》详细使用和说明,有时《CentOS下编译安装OpenJDK6过程》可能不完善、敬请谅解!如果《CentOS下编译安装OpenJDK6过程》有错误请给我们留言,我们将尽快修复文章错误,如果您觉得本站不错,请分享给周围的朋友!谢谢!

    顶一下
    (0)
    0%
    踩一下
    (0)
    0%
    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    验证码:点击我更换图片