Use CentOS to compile openjdk and use centos to compile openjdk
1. Overview
<Deep understanding of Java Virtual Machine-JVM advanced features and Best Practices> Chapter 1 describes how to compile jdk by yourself.
2. compiling environment
VMware12
CentOS-7-x86_64-Everything-1611
3. Software preparation
Bootstrap JDK: jdk-7u79-linux-x64.tar.gz
OpenJDK: https://jdk7.java.net/source.html
4. Compile Dependencies
4.1 install the alsa package
Yum-y install alsa-lib-devel
4.2 install cups-devel
Yum-y install cups-devel
4.3 install lib-related libraries
Yum-y install libX *
4.4 install gcc
Yum-y install gcc-c ++
4.5 install freetype
4.5.1 download http://rpm.pbone.net/index.php3/stat/4/idpl/26641422/dir/centos_7/com/freetype-2.4.11-9.el7.x86_64.rpm.htm
4.5.2 install rpm-ivh freetype-2.4.11-9.el7.x86_64.rpm
4.6 install ant
Yum-y install ant
Note: openjdk will be installed as dependencies. After installation, check whether java-version | ant-version is installed.
& Use ant.tar.gz to decompress the package. Do not install and configure jdk dependencies.
4.7 install libstdc ++
Yum-y install libstdc ++-static
Note: This installation solves compilation errors.ERROR: Cannot chcon libjvm.so
5. Configure the environment variable vim/etc/profile
Export CLASSPATH
Export JAVA_HOME
Export LANG = C
Export ALT_BOOTDIR =/usr/java/jdk1.7.0 _ 76
Export ALLOW_DOWNLOADS = true
Export USE_PRECOMPILED_HEADER = true
Export ARCH_DATA_MODEL = 64
Export HOTSPOT_BUILD_JOBS = 4
Export ALT_PARALLEL_COMPILE_JOBS = 4
Export SKIP_DEBUG_BUILD = false
Export SKIP_FASTDEBUG_BUILD = true
Export DEBUG_NAME = debug
Export ALT_OUTPUTDIR =/usr/java/openjdk/build
6. Compile check
Make sanity
If the output result is:Sanity check passed
, Indicating that the settings are correct.
7. Execute Compilation
Make
8. Other problems that may occur during compilation
8.1./gamma: relocation error: /usr/java/jdk1.7.0_76/jre/lib/amd64/libjava.so:
Delete all test_gamma files in/usr/java/openjdk/hotspot/make/linux/Makefile
(Vim Makefile->/test_gamma search->: % s/& \. \/test_gamma/g replace all)
8.2 Error: time is more than 10 years from present:
Change all time in the/usr/java/openjdk/jdk/src/share/classes/java/util/CurrencyDate. properties file to recent
Vim command/20 ..-search-> I modify-> esc exit I-> n next position-> I until all changes are completed
8.3 others
Make clean can be compiled
9. Result chart
10. debug jdk
/Usr/java/openjdk/build-debug/the content under the j2sdk-image is the debug jdk
Overwrite the original oracle jdk as the system jdk and configure the environment variable JAVA_HOME CLASSPATH PATH