阿里云 centos 6.8 源码编译 openjdk7

前言
在阿里云新开服务器进行的测试,之前只做过yum upgrade -y操作。
1.安装openjdk1.6
yum install java-1.6.0-openjdk-devel -y
2.安装alsa
yum -y install alsa-lib-devel
3.安装cups-devel
yum -y install cups-devel
4.安装libXi-devel
yum -y install libX*
5.安装ant
unzip apache-ant-1.9.7-bin.zip
ln -s /application/apache-ant-1.9.7/bin/ant /usr/bin/ant
6.安装freetype
tar -zvxf freetype-2.7.tar.gz
cd freetype-2.7
./configure
make
make install
shutdown -r now
7.解压源码
unzip openjdk-7u40-fcs-src-b43-26_aug_2013.zip
8.环境变量
vim /etc/profile
#将下列加入到末尾并保存
export JAVA_HOME=/etc/alternatives/java_sdk_1.6.0
export JRE_HOME=/etc/alternatives/java_sdk_1.6.0/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export ANT_HOME=/application/apache-ant-1.9.7
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH:$ANT_HOME/bin
export LANG=C
export ALT_BOOTDIR=/etc/alternatives/java_sdk_1.6.0
export BUILD_LANGTOOLS=true
export BUILD_CORBA=true
export BUILD_HOTSPOT=true
#export BUILD_JAXP=false
#export BUILD_JAXWS=false
export BUILD_JDK=true
export HOTSPOT_BUILD_JOBS=2
export ALT_PARALLEL_COMPILE_JOBS=2
export SKIP_COMPARE_IMAGES=true
export USE_PRECOMPILED_HEADER=true
export ALT_FREETYPE_LIB_PATH=/usr/local/lib
export ALLOW_DOWNLOADS=true
export SKIP_DEBUG_BUILD=false
export SKIP_FASTDEBUG_BUILD=true
export BUILD_INSTALL=false
export BUILD_DEPLOY=false
#export DEBUG_NAME=debug
export ALT_FREETYPE_HEADERS_PATH=/usr/local/include/freetype2
export ALT_OUTPUTDIR=/application/openjdk/build
export JDK_IMPORT_PATH=/etc/alternatives/java_sdk_1.6.0
export ALT_JDK_IMPORT_PATH=/etc/alternatives/java_sdk_1.6.0
unset CLASSPATH
unset JAVA_HOME
#刷新环境变量
source /etc/profile
9.健全检查
make sanity
输出Sanity check passed,检查通过
10.编译准备
这个时候如果直接编译会报错,所以提前做一些准备:
报错:
./gamma: relocation error: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.40.x86_64/jre/lib/amd64/libjava.so: symbol JVM_FindClassFromCaller, version SUNWprivate_1.1 not defined in file libjvm.so with link time reference

解决:
修改文件:hotspot/make/linux/Makefile
去掉文件中所有的test_gamma即可
vim hotspot/make/linux/Makefile
查找输入: /test_gamma
把含有高亮字符的行都注释掉
报错:
Error: time is more than 10 years from present: 1136059200000

  解决:
vim `find . -name "CurrencyData.properties"`
把所有时间改到10年内
11.编译
make 2>&1 | tee $ALT_OUTPUTDIR/build.log

 完美
12.测试

 
参考文档:
  1. 《深入理解JAVA虚拟机:JVM高级特性与最佳实践》
  2. http://jiangbo.me/blog/2012/02/10/compile-openjdk7-on-centos6/
  3. http://www.cnblogs.com/myresearch/p/build-openjdk7.html
  4. http://www.cnphp6.com/archives/122601
 
软件下载地址:
  1. OpenJDK™ Source:https://jdk7.java.net/source.html
  2. FreeType:https://sourceforge.net/projects/freetype/files/freetype2/
  3. Apache Ant:http://archive.apache.org/dist/ant/binaries/

猜你喜欢

转载自389708585.iteye.com/blog/2346341