首页 > 代码库 > Centos7编译openjdk7

Centos7编译openjdk7

准备环境:

操作系统: CentOS7 64位 

openjdk、jdk、ant资源下载

链接:http://pan.baidu.com/s/1o7NzZKm 密码:c8sw

依赖资源安装

  1. 安装alsa包 
    yum install alsa-lib-devel
  2. 安装cups-devel 
    yum install cups-devel
  3. 安装X相关的库 
    yum install libX*
  4. 安装g++ 
    yum install gcc gcc-c++
  5. 安装freetype 
    yum install freetype-devel
  6. 安装libstdc
    yum install libstdc++-static
  7. 安装ant 
    unzip apache-ant-1.8.2-bin.zip
  8. 设置环境变量 
    unset CLASSPATH unset JAVA_HOME // 语言选项,必须设置 export LANG=C // Bootstrap JDK的安装路径,必须设置 export ALT_BOOTDIR=/opt/jdk1.7.0_60// Ant的安装路径 export ANT_HOME=/opt/compile/apache-ant-1.8.2// 允许自动下载依赖 export ALLOW_DOWNLOADS=true // 预编译 export USE_PRECOMPILED_HEADER=true // 64位jdk export ARCH_DATA_MODEL=64 // 并行编译的线程数,设置为和CPU内核数量一致即可 export HOTSPOT_BUILD_JOB=4 export ALT_PARALLEL_COMPILE_JOBS=4 // 编译内容 export SKIP_DEBUG_BUILD=false export SKIP_FASTDEBUG_BUILD=true export DEBUG_NAME=debug // 输出路径 export ALT_OUTPUTDIR=/opt/compile/build-jdk
  9. 解压openjdk-7u40-fcs-src-b43-26_aug_2013.zip
    unzip openjdk-7u40-fcs-src-b43-26_aug_2013.zip
  10. 编译检查 
    进入解压后的openjdk目录下执行命令:make sanity 
    若输出结果为:Sanity check passed,表示检查通过
  11. 执行编译 
    执行命令:make,执行结束后如下,显示每个模块的编译所用时长:
  12. #-- Build times ----------Target debug_buildStart 2016-09-05 08:01:45End   2016-09-05 08:38:1700:03:31 corba00:09:33 hotspot00:00:36 jaxp00:00:45 jaxws00:20:55 jdk00:01:12 langtools00:36:32 TOTAL-------------------------
  13. 配置debug版jdk 
    /opt/compile/build-jdk-debug/j2sdk-image下内容为debug版jdk,将其复制到%JAVA_HOME%下,替换Oracle JDK。
  14. 查看jdk版本信息 
    [root@localhost ~]# java -version 

    openjdk version "1.7.0-internal-debug"
    OpenJDK Runtime Environment (build 1.7.0-internal-debug-root_2016_09_05_07_41-b00)
    OpenJDK 64-Bit Server VM (build 24.0-b56-jvmg, mixed mode)

问题 Error: time is more than 10 years from present: 1120165200000

Error: time is more than 10 years from present: 1120165200000java.lang.RuntimeException: time is more than 10 years from present: 1120165200000    at 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[5]: *** [/root/openjdk/build/../build-debug/lib/currency.data] Error 1make[5]: Leaving directory `/root/Downloads/openjdk/jdk/make/java/java‘make[4]: *** [all] Error 1make[4]: Leaving directory `/root/Downloads/openjdk/jdk/make/java‘make[3]: *** [all] Error 1make[3]: Leaving directory `/root/Downloads/openjdk/jdk/make‘make[2]: *** [jdk-build] Error 2make[2]: Leaving directory `/root/Downloads/openjdk‘make[1]: *** [generic_debug_build] Error 2make[1]: Leaving directory `/root/Downloads/openjdk‘make: *** [build_debug_image] Error 2

解决方法:报错的位置是openjdk目录下jdk/src/share/classes/java/util/CurrencyData.properties文件,将此文件中所有的时间改为10年以内即可

Centos7编译openjdk7