最近在学习《深入理解java虚拟机 第二版》这本书。书中第一部分建议大家自己编译OpenJDK。抱着学习态度也来编译个玩一玩。下面进入正题。
1.编译环境介绍
操作系统 | CentOS Linux release 7.1.1503 (Core) |
Linux内核版本 | 3.10.0-229.el7.x86_64 |
gcc版本 | 4.8.2 20140120 (Red Hat 4.8.2-16) (GCC) |
openJdk版本 | openjdk-7u40 |
2.准备工作
2.1下载OpenJDK
Note that some Linux systems have a habit of pre-populating your environment variables for you, for example JAVA_HOME might get pre-defined for you to refer to the JDK installed on your Linux system. You will need to unset JAVA_HOME. It's a good idea to run env and verify the environment variables you are getting from the default system settings make sense for building the OpenJDK. |
先检查一下本地是否配置有JAVA_HOME
Bootstrap JDK All OpenJDK builds require access to the previously released JDK 6, this is often called a bootstrap JDK. The JDK 6 binaries can be downloaded from Sun's JDK 6 download site. For build performance reasons is very important that this bootstrap JDK be made available on the local disk of the machine doing the build. You should always set ALT_BOOTDIR to point to the location of the bootstrap JDK installation, this is the directory pathname that contains a bin, lib, and include It's also a good idea to also place its bin directory in the PATH environment variable, although it's not required. |
Certificate Authority File (cacert)See http://en.wikipedia.org/wiki/Certificate_Authority for a better understanding of the Certificate Authority (CA). A certificates file named "cacerts" represents a system-wide keystore with CA certificates. In JDK and JRE binary bundles, the "cacerts" file contains root CA certificates from several public CAs (e.g., VeriSign, Thawte, and Baltimore). The source contain a cacerts file without CA root certificates. Formal JDK builders will need to secure permission from each public CA and include the certificates into their own custom cacerts file. Failure to provide a populated cacerts file will result in verification errors of a certificate chain during runtime. The variable ALT_CACERTS_FILE can be used to override the default location of the cacerts file that will get placed in your build. By default an empty cacerts file is provided and that should be fine for most JDK developers.
|
gmake是GNU Make的缩写。
Linux系统环境下的make就是GNU Make,之所以有gmake,是因为在别的平台上,make一般被占用,GNU make只好叫gmake了。
|
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)
Start 2016-01-10 11:18:43
End 2016-01-10 11:52:15
00:00:15 corba
00:00:21 hotspot
00:00:11 jaxp
00:00:20 jaxws
00:32:15 jdk
00:00:10 langtools
00:33:32 TOTAL
drwxr-xr-x. 2 root root 4096 Jan 9 16:53 fastdebug
drwxr-xr-x. 7 root root 4096 Jan 9 16:56 generated
drwxr-xr-x. 2 root root 4096 Jan 9 16:53 jvmg
drwxr-xr-x. 2 root root 4096 Jan 9 16:53 optimized
drwxr-xr-x. 3 root root 20480 Jan 10 11:19 product
drwxr-xr-x. 2 root root 4096 Jan 9 16:53 profiled
LD_LIBRARY_PATH=.:${JAVA_HOME}/jre/lib/amd64/native_threads:${JAVA_HOME}/jre/lib/amd64:/opt/openJDKroom/openjdk/build/linux-amd64/hotspot/outputdir/linux_amd64_compiler2/product
export LD_LIBRARY_PATH
下面贴出我这个文件的完整内容:
# Generated by /opt/openJDKroom/openjdk/hotspot/make/linux/makefiles/buildtree.make # add LD_LIBRARY_PATH=.:${JAVA_HOME}/jre/lib/amd64/native_threads:${JAVA_HOME}/jre/lib/amd64:/opt/openJDKroom/openjdk/build/linux-amd64/hotspot/outputdir/linux_amd64_compiler2/product |
下面执行:
# source ./env.sh
# ./gamma -version
Using java runtime at: /opt/openJDKroom/openjdk/build/linux-amd64/j2sdk-image/jre
openjdk version "1.7.0-internal"
OpenJDK Runtime Environment (build 1.7.0-internal-root_2016_01_10_00_16-b00)
OpenJDK 64-Bit Server VM (build 24.0-b56, mixed mode)
运行成功!!
希望对想要编译openJDK的朋友有个参考。如果有疑问请提出,大家一起学习探讨。>_<