OpenJDK6 compilation and Installation Process in CentOS
Due to the initial manual compilation of OpenJDK6, there are still a lot of pitfalls and various independencies and wonderful things, we hereby record them and send them to the future.
Compilation environment information:
[root@dev-52 ~]# uname -aLinux dev-52 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64 x86_64 x86_64 GNU/Linux[root@dev-52 openjdk6]# arch && cat /etc/centos-release x86_64CentOS release 6.2 (Final)[root@dev-52 openjdk6]# nproc 8[root@dev-52 ~]# free -m total used free shared buffers cachedMem: 7872 7695 176 0 158 6794-/+ buffers/cache: 742 7129Swap: 5823 0 5823
OpenJDK version:Openjdk-6-src-b27-26_oct_2012.tar.gz: https://java.net/projects/openjdk6/downloads/
[Root @ dev-52 ~] # Mkdir openjdk6 & tar xf openjdk-6-src-b27-26_oct_2012.tar.gz-C openjdk6 [root @ dev-52 ~] # Ll openjdk6 general plan -- 1 uucp 143 1503 2012-10-27 ASSEMBLY_EXCEPTIONdrwxrwxr-x 4 uuucp 143 4096 2012-10-27 corba-rw-r -- 1 uucp 143 1373 2012-10-27 get_source.shdrwxrwxr-x 6 uuucp 143 4096 hotspotdrwxrwxr-x 5 uucp 143 4096 143 release-x 5 uucp 4096 143 4096 release-x 5 UCP jdkdrwxrwxr-x 5 uucp 1 43 4096 langtools-rw-r -- 1 uucp 143 19263 LICENSEdrwxrwxr-x 4 uucp 143 4096 143 make-rw-r -- 1 uucp 14485 makefile-rw-r -- 1 uucp 143 1803 README-rw-r -- 1 uucp 143 101427 README-builds.html-rw-rw-r -- 1 uucp 143 4807 1_drwxrwxr- x 2 uucp 143 4096 7 test-rw-r -- 1 uucp 143 127498 2012-10-27 THIRD_PARTY_README-rw-rw-r -- 1 uucp 143 2113 2012-10-27 TRADEMARK # Install dependencies. To compile OpenJDK, install a JDK first, both OpenJDK and Oracle JDK can be used [root @ dev-52 ~] # Yum install java-1.6.0-openjdk alsa-lib-devel gawk binutils libpng-devel freetype-devel openmotif-devel cups-devel ant libXtst-devel-y # Write All compilation parameters to a script [root @ dev-52 openjdk6] # cd openjdk6 [root @ dev-52 openjdk6] # vim build. sh #! /Bin/bashexport OPENJDK_HOME =/root/openjdk6 # extract the source package location export LANG = Cexport ALT_BOOTDIR =/usr/lib/jvm/java-1.6.0-openjdk.x86_64 # The existing JDK location on the machine, the following is the same as export ALT_JDK_IMPORT_PATH =/usr/lib/jvm/java-1.6.0-openjdk.x86_64export ALT_OUTPUTDIR = $ OPENJDK_HOME/build # compile the output directory export ALLOW_DOWNLOADS = trueexport HOTSPOT_BUILD_JOBS = 8 # Number, when the number of CPU cores is the same, you can use export ALT_PARALLEL_COMPILE_JOBS = 8 export DEV_ONLY = trueexport USE_PREC. OMPILED_HEADER = trueexport BUILD_LANGTOOLS = trueexport BUILD_JAXP = false # the following three components need to be downloaded from the network during compilation, it takes a long time and is useless to the author to cancel compilation of export = falseexport BUILD_CORBA = falseexport BUILD_HOTSPOT = trueexport BUILD_JDK = trueexport release = false # cancel building deployment and installation package export BUILD_INSTALL = falseunset Java CLASSPATHmake sanity # verify [root @ dev-52 openjdk6] # chmod + x build. sh [root @ dev-52 openjdk6] #. /build. sh # Since the output content is too long to take up a large amount of space, it is not completely pasted out. the output at the end is as follows: WARNING: You are not building the JAXP sources. the jaxp files will be obtained from the location set in ALT_JDK_IMPORT_PATH. WARNING: You are not building the JAXWS sources. the jaxws files will be obtained from the location set in ALT_JDK_IMPORT_PATH. WARNING: You are not building the CORBA sources. the corba files will be obtained from the location set in ALT_JDK _ IMPORT_PATH. WARNING: Your build environment has the variable DEV_ONLY defined. this will result in a development-only build of the JDK, lacking the documentation build and installation bundles. sanity check passed. # Check passed # modify build. the last line of sh is as follows, and then the script is executed here: make sanity & make 2> & 1 | tee $ ALT_OUTPUTDIR/build. log [root @ dev-52 openjdk6] #. /build. sh # the following exceptions may occur since January 1, 2015:/opt/jdk1.6.0 _ 31/bin/java-Xmx896m-X Ms128m-XX: PermSize = 32 m-XX: MaxPermSize = 160 m-jar/root/openjdk6/build/btjars/generatecurrencydata. jar-o/root/openjdk6/build/lib/currency. data. temp \ <.. /.. /.. /src/share/classes/java/util/CurrencyData. propertiesError: time is more than 10 years from present: 1120165200000java. lang. runtimeException: time is more than 10 years from present: 1120165200000 at build. tools. generatecurrencydata. genera TeCurrencyData. makeSpecialCaseEntry (GenerateCurrencyData. java: 285) at build. tools. generatecurrencydata. generateCurrencyData. buildMainAndSpecialCaseTables (GenerateCurrencyData. java: 225) at build. tools. generatecurrencydata. generateCurrencyData. main (GenerateCurrencyData. java: 154) make [4]: *** [/root/openjdk6/build/lib/currency. data] Error 1 # modify CurrencyData. properties file, change the time before 10 years to 10 years. # Some amd64 racks The following error may occur on the created machine: cd linux_amd64_compiler2/product &&. /test_gammajava full version "1.6.0 _ 36-b36 ". /gamma: relocation error:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.36.x86_64/jre/lib/amd64/libjava. so: symbol JVM_FindClassFromCaller, version SUNWprivate_1.1 not defined in file libjvm. so with link time reference # is mainly caused by a bug in OpenJDK. Replace OpenJDK with Oracle JDK. Make sure to modify the build at the same time. sh Content [root @ dev-52 openjdk6] # vim 'Find. -name 'currencydata. properties ''# The output at the end of the compilation is as follows. You can also check the exit code of the program: >>> making sec-files-win @ Mon Sep 7 15:06:20 CST 2015... >>> making jgss-files @ Mon Sep 7 15:06:20 CST 2015... >>> finished making images @ Mon Sep 7 15:06:20 CST 2015... make [2]: Leaving directory '/root/openjdk6/jdk/make' make [1]: Leaving directory '/root/openjdk6 'control linux amd64 1.6.0-internal build_product_image build finished: 15-09-07 15: 06 Control linux amd64 1.6.0-internal all_product_build build finished: 15-09-07 15: 06 Control linux amd64 1.6.0-internal all build finished: 15-09-07 [root @ dev-52 openjdk6] # echo $? 0 # exit code is 0 indicates that the program Exits normally, compiled successfully into the output directory of the j2sdk-image, you can see that the compiled JDK [root @ dev-52 openjdk6] # cd build/j2sdk-image/bin [root @ dev-52 j2sdk-image] # lsASSEMBLY_EXCEPTION bin demo include jre lib LICENSE man sample src.zip THIRD_PARTY_README [root @ dev-52 bin] #. /java-versionopenjdk version "1.6.0-internal" OpenJDK Runtime Environment (build 1.6.0-internal-root_07_sep_2015_14_49-b00) OpenJDK 64-Bit Server VM (build between 0-b12, mixed mode)
The entire compilation process is over. Of course, the first compilation won't be completed so smoothly, so you need to be careful in the operation. Of course, compiling OpenJDK7 is similar, the dependent package names on the debain platform may be different. OK. If you are interested in JVM, try it yourself.
References
- Deep understanding of Java Virtual Machine: Advanced JVM features and best practices by Zhou Zhiming
- Http://blog.csdn.net/bysun2013/article/details/41984335
- Http://openjdk.java.net/