1. 程式人生 > >Centos編譯OpenJDK7原始碼

Centos編譯OpenJDK7原始碼

一、寫在前面

1.Centos版本:CentOS Linux release 7.3.1611 (Core)  x86_64

2.ant版本:apache-ant-1.9.13 

3.freetype版本:freetype-2.3.12

4.openjdk版本:openjdk-7u6-fcs-src-b24-28_aug_2012

5.jdk版本:jdk1.6.0_45

二、安裝jdk必備軟體包

yum -y groupinstall 'base'
yum -y install make
yum -y install alsa-lib-devel
yum -y install cups-devel
yum -y install libXi-devel
yum -y install gcc gcc-c++
yum -y install libX*
yum -y install libstdc++-static.i686
yum -y install libstdc++-static.x86_64


三、下載相關資源(存放到/mnt/application/tools中)

1.freetype-2.3.12.tar.gz

下載地址:https://sourceforge.net/projects/freetype/files/freetype2/2.3.12/freetype-2.3.12.tar.gz/download

2.apache-ant-1.9.13-bin.zip

下載地址:http://archive.apache.org/dist/ant/binaries/apache-ant-1.9.13-bin.zip

3.openjdk-7u6-fcs-src-b24-28_aug_2012.zip

下載地址:http://www.java.net/download/openjdk/jdk7/promoted/b24/openjdk-7u6-fcs-src-b24-28_aug_2012.zip

4.jdk-6u45-linux-x64.bin (存放到/mnt/application/java中)

下載地址:https://www.oracle.com/technetwork/java/javase/downloads/java-archive-downloads-javase6-419409.html

備註:已將以上資源打包上傳到CSDN:https://download.csdn.net/download/szstudy/10712108

四、編譯安裝配置環境

1.編譯安裝freetype:

[[email protected] tools]#tar -xzf freetype-2.3.12.tar.gz
[[email protected] tools]# cd freetype-2.3.12
[[email protected] freetype-2.3.12]#./configure 
[[email protected] freetype-2.3.12]#make
[[email protected] freetype-2.3.12]#make install


2.安裝JDK:

[[email protected] java]#chmod a+x jdk-6u45-linux-x64.bin

[[email protected] java]#./jdk-6u45-linux-x64.bin 

配置環境變數(配置檔案/etc/profile)

JAVA_HOME=/mnt/application/java/jdk1.6.0_45
export JRE_HOME=mnt/application/java/jdk1.6.0_45/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

使環境變數生效:

 [[email protected] etc]#source profile

驗證:

[[email protected] openjdk]# java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

3.安裝ant:

[[email protected] tools]#unzip apache-ant-1.9.13-bin.zip 
[[email protected] tools]#ln -s /mnt/application/tools/apache-ant-1.9.13/bin/ant /usr/bin/ant

驗證:

[[email protected] tools]#ant
Buildfile: build.xml does not exist!
Build failed

4.配置環境變數(配置檔案/etc/profile)

nset CLASSPATH
unset JAVA_HOME
export LANG=C
export ALT_BOOTDIR=/mnt/application/java/jdk1.6.0_45
export ANT_HOME=/mnt/application/tools/apache-ant-1.9.13/
export ALT_FREETYPE_LIB_PATH=/usr/local/lib
export SKIP_DEBUG_BUILD=false
export SKIP_FASTDEBUG_BUILD=true
export DEBUG_NAME=debug
export ALT_FREETYPE_HEADERS_PATH=/usr/local/include/freetype2

使環境變數生效:

 [[email protected] etc]#source profile

5.修改/mnt/application/tool/openjdk/jdk/src/share/classes/java/util/CurrencyData.properties

修改108行
AZ=AZM;2009-12-31-20-00-00;AZN
修改381行
MZ=MZM;2009-06-30-22-00-00;MZN
修改443行
RO=ROL;2009-06-30-21-00-00;RON
修改535行
TR=TRL;2009-12-31-22-00-00;TRY
修改561行
VE=VEB;2009-01-01-04-00-00;VEF

 

6.檢查環境

[[email protected] openjdk]# make sanity
....
....
....
....
Previous JDK Settings:
  PREVIOUS_RELEASE_PATH = USING-PREVIOUS_RELEASE_IMAGE
    ALT_PREVIOUS_RELEASE_PATH = 
  PREVIOUS_JDK_VERSION = 1.6.0
    ALT_PREVIOUS_JDK_VERSION = 
  PREVIOUS_JDK_FILE = 
    ALT_PREVIOUS_JDK_FILE = 
  PREVIOUS_JRE_FILE = 
    ALT_PREVIOUS_JRE_FILE = 
  PREVIOUS_RELEASE_IMAGE = /mnt/application/java/jdk1.6.0_45
    ALT_PREVIOUS_RELEASE_IMAGE = 


Sanity check passed.

7.編譯

[[email protected] openjdk]# make all
Build times ----------
Target debug_build
Start 2015-05-05 09:34:37
End 2015-05-05 10:24:33
00:05:23 corba
00:10:49 hotspot
00:00:55 jaxp
00:01:07 jaxws
00:30:05 jdk
00:01:36 langtools
00:49:56 TOTAL
-------------------------
make[1]: Leaving directory `/application/tools/openjdk'

8.檢視是否編譯成功

[[email protected] openjdk]#  ./build/linux-amd64/bin/java -version
openjdk version "1.7.0-internal-debug"
OpenJDK Runtime Environment (build 1.7.0-internal-debug-root_2018_10_10_18_56-b00)
OpenJDK 64-Bit Server VM (build 23.2-b09-jvmg, mixed mode)

 

 

 

 

參考:http://www.cnblogs.com/myresearch/p/build-openjdk7.html