Foreword
I spent three days working on openJDK on windows. I was not familiar with bash. I was exhausted by various inexplicable dependencies and bugs in scripts. In the end, an inexplicable error occurred when making all, saying that there was warning and -Werror was set to true. I didn't google to -Werror, so I had to give it up.
Today this rookie suddenly remembered that I still have an Ubuntu virtual machine. I have the right to give it a try, but I didn't expect it to succeed easily.
Platform: Ubuntu Version 5.1.30 (3.2.0-98-generic-pae #138-Ubuntu SMP Mon Jan 11 13:11:12 UTC 2016 i686 i686 i386 GNU/Linux)
Step 1: (Follow the commands in "Understanding Java Virtual Machine") One-click download dependencies
sudo apt-get install build-essential gawk m4 libasound2-dev libcups2-dev libxrender-dev xorg-dev xutils-dev x11proto-print-dev binutils libmotif3 libmotif-dev ant
It may not be all written here, but for the time being, install it first. If you lack any dependencies in the future, you can install it according to the prompts. A Buddhist programmer’s day is a trick.
The source code of openJDK has C++ and Java, so a Bootstrap JDK is needed to compile the Java part. This JDK is usually an official JDK that is one version earlier than the openJDK you want to compile. This is what the official README-builds (under the source code root directory downloaded in the second step) says:
…The general rule is that the bootstrap JDK must be an instance of the previous major release of the JDK.
The README-builds of each version will indicate the specific version of Bootstrap JDK required by this version of openJDK. For example, openJDK8 requires a version above JDK7u7, but not JDK8:
Step 2: Download the source code
sudo hg clone http://hg.openjdk.java.net/jdk8u/jdk8u-dev/
cd jdk8u-dev
chmod 755 get_source.sh
. /get_source.sh
Download the latest source code of jdk8u with mercurial. If you want to download other versions of the source code, you can browse here: http://hg.openjdk.java.net/. This download process takes about thirty minutes.
If you don’t want to use mercurial, you can also download the zip package here: http://jdk.java.net/java-se-ri/8 (at the RI source code at the bottom of the page):
I used this zip package to decompress and compile when I compiled on windows, and it failed in the end. Out of superstition, I still decided to use mercurial to download on Ubuntu, and all the gods can ignore it.
Step 3: Set environment variables and create a new setup.sh, and copy the following content into it:
export LANG=C
# BootStrap-JDK installation path, replace with bootstrap-JDK path
export ALT_BOOTDIR=/usr/lib/jvm/java-7-oracle-1.7.0.80export ALLOW_DOWNLOADS=trueexport HOTSPOT_BUILD_JOBS=8export SKIP_COMPARE_IMAGES=true
# The content to be compiled, readers can choose according to their needs
export BUILD_LANGTOOLS=true
# export BUILD_JAXWS=false
# export BUILD_JAXP=false
# export BUILD_CORBA=falseexport BUILD_HOTSPOT=trueexport BUILD_JDK=trueexport SKIP_COMPARE_IMAGES=true
BUILD_DEPLOY=false
BUILD_INSTALL=false
# The path where the compilation result is stored, it is recommended to store it in the build folder in the openjdk source code
export ALT_OUTPUTDIR=/usr/dev/jvm/openjdk/build
# These two environment variables need to be removed, otherwise there will be problems
unset JAVA_HOME
unset CLASSPATH
run
. /setup.sh
Just set it up again.
Step 4: Compile
It will take about 20 to 30 minutes to run make in the root directory of the good openJDK source code. It was supposed to run make sanity, but I encountered this error again...
Damn what the hell, there was no result after searching for a while, so the chicken thief skipped this step and ran make directly, and it succeeded. The output after success looks like this:
to sum up
The above is the entire content of this article. I hope that the content of this article has a certain reference value for your study or work. If you have any questions, you can leave a message and exchange. Thank you for your support to ZaLou.Cn.
Recommended Posts