OpenJDK的编译以及遇到的问题

安装必要软件

  1. 安装JDK6
    将jdk-6u24-linux-i586.bin文件上传到CentOS上
    如果没有执行权限,先执行如下命令
     
           
    1
     
           
    chmod 777 ./jdk -6u24-linux-i586.bin

执行安装程序

 
     
1
 
     
./jdk -6u24-linux-i586.bin

配置环境变量,修改/etc/profile文件,增加如下的内容

 
     
1
2
3
4
5
6
 
     
JAVA_HOME= /home/linxm /jdk1.6.0_24
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/ lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
  1. linux声音框架
    Advanced Linux Sound Architecture (ALSA) (Linux only)

     
           
    1
     
           
    yum install alsa- lib-devel
  2. 打印框架
    Common UNIX Printing System (CUPS) Headers (Solaris & Linux)

     
           
    1
     
           
    yum install cups-devel
  3. 安装X相关的库

     
           
    1
     
           
    yum install libX*
  4. 安装g++

     
           
    1
     
           
    yum install gcc gcc - c + +
  5. 安装FreeType2
    为访问字体文件提供了一套统一的、独立于字体文件类型的、简单而易用的API。通常上面的步骤执行之后,已经自动安装了

  6. ANT安装
     
           
    1
    2
    3
    4
     
           
    # 下载文件
    wget http:/ /archive.apache.org/dist /ant/binaries /apache-ant-1.7.1-bin.tar.gz
    tar -zxvf apache-ant-1.7.1-bin.tar.gz
    mv apache-ant-1.7.1 /usr /local/ant

编辑配置文件/etc/profile,怎讲如下的内容

 
     
1
2
3
 
     
ANT_HOME=/usr/ local/ant
PATH= $JAVA_HOME/bin: ${ANT_HOME}/bin: $PATH
export ANT_HOME

为了马上生效,执行下面的命令

 
     
1
 
     
source /etc/profile

进行必要的环境变量配置

修改/etc/profile文件,增加如下的内容

 
     
1
2
3
4
5
6
 
     
export LANG=C
export ALT_BOOTDIR= $JAVA_HOME
export ALT_JDK_IMPORT_PATH= $JAVA_HOME
export ALLOW_OWNLOADS= true
unset CLASSPATH
unset JAVA_HOME

进行编译

  1. 将OpenJDK代码上传到CentOS上
  2. 进入OpenJDK目录内
  3. 进行make检查
    执行命令
     
           
    1
     
           
    make sanity

如果没有问题执行编译

 
     
1
 
     
make

问题解决

  1. 编译中发生 cannot find -lstdc++错误
     
           
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
     
           
    Linking vm...
    /usr/bin/ld: cannot find -lstdc++
    collect2: error: ld returned 1 exit status
    ln: failed to access 'libjvm.so .1': Too many levels of symbolic links
    /usr/bin/objcopy --only-keep- debug libjvm.so libjvm.debuginfo
    /usr/bin/objcopy: Warning: could not locate 'libjvm.so'. reason: Too many levels of symbolic links
    make[ 6]: *** [libjvm.so] Error 1
    make[ 6]: Leaving directory `/home/linxm/openjdk/build/linux-amd64/hotspot/outputdir/linux_amd64_compiler2/product'
    make[ 5]: *** [the_vm] Error 2
    make[ 5]: Leaving directory `/home/linxm/openjdk/build/linux-amd64/hotspot/outputdir/linux_amd64_compiler2/product'
    make[ 4]: *** [product] Error 2
    make[ 4]: Leaving directory `/home/linxm/openjdk/build/linux-amd64/hotspot/outputdir'
    make[ 3]: *** [generic_build2] Error 2
    make[ 3]: Leaving directory `/home/linxm/openjdk/hotspot/ make'
    make[ 2]: *** [product] Error 2
    make[ 2]: Leaving directory `/home/linxm/openjdk/hotspot/ make'
    make[ 1]: *** [hotspot-build] Error 2
    make[ 1]: Leaving directory `/home/linxm/openjdk'
    make: *** [build_product_image] Error 2

解决方法

 
     
1
2
 
     
yum search libc + +  
yum install libstdc + + - static
  1. 发现libjvm.so软连接死循环问题
     
           
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
     
           
    Linking vm...
    /usr/bin/ld: cannot open output file libjvm.so: Too many levels of symbolic links
    collect2: error: ld returned 1 exit status
    ln: failed to access 'libjvm.so': Too many levels of symbolic links
    ln: failed to access 'libjvm.so .1': Too many levels of symbolic links
    /usr/bin/objcopy --only-keep- debug libjvm.so libjvm.debuginfo
    /usr/bin/objcopy: Warning: could not locate 'libjvm.so'. reason: Too many levels of symbolic links
    make[ 6]: *** [libjvm.so] Error 1
    make[ 6]: Leaving directory `/home/linxm/openjdk/build/linux-amd64/hotspot/outputdir/linux_amd64_compiler2/product'
    make[ 5]: *** [the_vm] Error 2
    make[ 5]: Leaving directory `/home/linxm/openjdk/build/linux-amd64/hotspot/outputdir/linux_amd64_compiler2/product'
    make[ 4]: *** [product] Error 2
    make[ 4]: Leaving directory `/home/linxm/openjdk/build/linux-amd64/hotspot/outputdir'
    make[ 3]: *** [generic_build2] Error 2
    make[ 3]: Leaving directory `/home/linxm/openjdk/hotspot/ make'
    make[ 2]: *** [product] Error 2
    make[ 2]: Leaving directory `/home/linxm/openjdk/hotspot/ make'
    make[ 1]: *** [hotspot-build] Error 2
    make[ 1]: Leaving directory `/home/linxm/openjdk'
    make: *** [build_product_image] Error 2

我进入home/linxm/openjdk/build/linux-amd64/hotspot/outputdir/linux_amd64_compiler2/product目录,发现libjvm.so文件不存在,具体什么原因导致不清楚

 
     
1
2
3
 
     
make clean
make sanity
make
  1. 发现超过10年的问题
     
           
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
           
    Error: time is more than 10 years from present: 1136059200000
    java.lang.RuntimeException: time is more than 10 years from present: 1136059200000
    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[ 4]: *** [/home/linxm/openjdk/build/linux-amd64/ lib/currency.data] Error 1
    make[ 4]: Leaving directory `/home/linxm/openjdk/jdk/ make/java/java'
    make[ 3]: *** [all] Error 1
    make[ 3]: Leaving directory `/home/linxm/openjdk/jdk/ make/java'
    make[ 2]: *** [all] Error 1
    make[ 2]: Leaving directory `/home/linxm/openjdk/jdk/ make'
    make[ 1]: *** [jdk-build] Error 2
    make[ 1]: Leaving directory `/home/linxm/openjdk'
    make: *** [build_product_image] Error 2

修改/jdk/src/share/classes/java/util/CurrencyData.properties文件
将其中10年以前的时间都设置到10年以内

验证

编译成功

 
     
1
2
3
4
5
6
7
8
9
10
11
12
13
 
     
#-- Build times ----------
Target all _product_build
Start 2016-11-29 15:29:09
End 2016-11-29 15:55:26
00:00:22 corba
00:00:22 hotspot
00:00:04 jaxp
00:00:11 jaxws
00:25:11 jdk
00:00:05 langtools
00:26:16 TOTAL
-------------------------
make[1]: Leaving directory `/home/linxm/openjdk'

查看一下版本

 
     
1
2
 
     
cd build/linux-amd64/bin
./java - version

显示如下内容

 
     
1
2
3
 
     
openjdk version "1.7.0-internal"
OpenJDK Runtime Environment ( build 1. 7. 0-internal-root_2016_11_29_14_43- b00)
OpenJDK 64- Bit Server VM ( build 24. 0- b56, mixed mode)

设置一下路径

 
     
1
2
3
 
     
export JAVA_HOME= /home/linxm /openjdk/build /linux-amd64
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/ lib/dt.jar:$JAVA_HOME/lib/tools.jar

可以书写一个最基本的Java程序运行一下!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值