編譯環(huán)境:
[操作系統(tǒng)]: CentOS7 64位
BootStrap JDK: 1.8.0_141
[root@localhost jdk8u-6d91dff0d6f1]# uname -a
Linux localhost.localdomain 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost jdk8u-6d91dff0d6f1]# java -version
openjdk version "1.8.0_141"
OpenJDK Runtime Environment (build 1.8.0_141-b16)
OpenJDK 64-Bit Server VM (build 25.141-b16, mixed mode)
- 下載openjdk源碼
hg clone http://hg.openjdk.java.net/jdk8u/jdk8u jdk8u
$ cd jdk8u
$ bash ./get_source.sh
如果因網(wǎng)速等原因下載不成功浸锨,可以先在瀏覽器打開代碼庫:
點(diǎn)擊左邊gz蝌箍,下載gz包佣蓉。我下載的為jdk8u-6d91dff0d6f1.tar.gz
解壓后:進(jìn)入目錄jdk8u-6d91dff0d6f1项戴,執(zhí)行以下命令:
hg init jdk8u-6d91dff0d6f1
創(chuàng)建hgrc文件
[root@localhost jdk8u-6d91dff0d6f1]# cat .hg/hgrc
[paths]
default = http://hg.openjdk.java.net/jdk8u/jdk8u
default-pull = http://hg.openjdk.java.net/jdk8u/jdk8u
[ui]
username = Weimin Sun
chmod +x ./get_source.sh
bash ./get_source.sh
- 安裝編譯環(huán)境
安裝alsa包
yum install alsa-lib-devel
安裝cups-devel
yum install cups-devel
安裝X相關(guān)的庫
yum install libX*
yum install xrender
安裝g++
yum install gcc gcc-c++
安裝freetype
yum install freetype
安裝ant
yum install ant
yum install ccache
- 設(shè)置環(huán)境變量
source build_jdk.env
內(nèi)容如下:
unset CLASSPATH
unset JAVA_HOME
編譯配置
./configure
或者
./configure --with-debug-level=fastdebug執(zhí)行編譯
make all
完成后會(huì)看到:
----- Build times -------
Start 2017-08-09 15:22:18
End 2017-08-09 15:57:08
00:00:44 corba
00:00:58 demos
00:04:56 docs
00:16:59 hotspot
00:01:17 images
00:00:26 jaxp
00:00:36 jaxws
00:07:33 jdk
00:00:58 langtools
00:00:22 nashorn
00:34:50 TOTAL
-------------------------
Finished building OpenJDK for target 'all'
- 配置jdk
便宜機(jī)器jdk環(huán)境:
[root@localhost bin]# java -version
openjdk version "1.8.0_141"
OpenJDK Runtime Environment (build 1.8.0_141-b16)
OpenJDK 64-Bit Server VM (build 25.141-b16, mixed mode)
編譯后jdk目錄:
[root@localhost bin]# pwd
/root/openjdk/jdk8u40/build/linux-x86_64-normal-server-release/jdk/bin
設(shè)置JAVA_HOME 和PATH
[root@localhost bin]# export JAVA_HOME=/root/openjdk/jdk8u40/build/linux-x86_64-normal-server-release/jdk
[root@localhost bin]# export PATH=/root/openjdk/jdk8u40/build/linux-x86_64-normal-server-release/jdk/bin:$PATH
[root@localhost bin]# java -version
openjdk version "1.8.0-internal"
OpenJDK Runtime Environment (build 1.8.0-internal-root_2017_08_09_15_21-b00)
OpenJDK 64-Bit Server VM (build 25.40-b25, mixed mode)