How to easily compile openJDK in Ubuntu

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

How to easily compile openJDK in Ubuntu
How to install Helm in Ubuntu
How to use hanlp in ubuntu
How to compile ijkplayer-android under ubuntu
How to install mysql in Ubuntu 14.04
How to install mysql in Ubuntu 14.04
How to compile and install PHP and Nginx in Ubuntu environment
How to add swap partition in Ubuntu
How to install cuda10.1 driver in Ubuntu
How to add users to Sudoers in Ubuntu
How to delete redundant kernels in Ubuntu
How to delete redundant kernels in Ubuntu
How to install ROS Noetic in Ubuntu20.04
How to set static IP in ubuntu14.04
How to modify software source in Ubuntu 7.10
How to open root account in Ubuntu20.04
How to hide applications in Ubuntu Dash?
How to upgrade to Ubuntu 20.04
How to upgrade to Ubuntu 20.04
How to modify time zone and time in ubuntu
How to configure TensorFlow use environment in Ubuntu
How to install python in ubuntu server environment
How to use dpkg command in Ubuntu system
How to open the ubuntu system in win10
How to configure /var/log/messages in Ubuntu system log
How to compile and install xdebug from source code in Ubuntu environment
How to install Hadoop in standalone mode on Ubuntu 18.04
How to view detailed network routing table in Ubuntu
How to use Putty to log in to ubuntu installed in VirtualBox
How to modify time zone and time in ubuntu system
Example of how to modify ip address in Ubuntu20.04
How to create a Python virtual environment in Ubuntu 14.04
How to upgrade to Ubuntu 16.04 LTS
How to control the ubuntu system in win10 through ssh
How to install memcache and start it in ubuntu environment
How to map shared disk to window in linux under Ubuntu
How to install Ruby on Ubuntu 20.04
How to install Memcached on Ubuntu 20.04
How to install Java on Ubuntu 20.04
How to install MySQL on Ubuntu 20.04
How to install VirtualBox on Ubuntu 20.04
How to install Elasticsearch on Ubuntu 20.04
How to install Protobuf 3 on Ubuntu
How to install Nginx on Ubuntu 20.04
How to install Apache on Ubuntu 20.04
How to install Git on Ubuntu 20.04
How to install Node.js on Ubuntu 16.04
How to install MySQL on Ubuntu 20.04
How to wrap in python code
How to install PHP7.4 in CentOS
How to install Vagrant on Ubuntu 20.04
How to install Bacula-Web on Ubuntu 14.04
How to install PostgreSQL on Ubuntu 16.04
How to install Git on Ubuntu 20.04
How to install Anaconda3 on Ubuntu 18.04
How to install Memcached on Ubuntu 18.04
How to install Jenkins on Ubuntu 16.04
How to install MemSQL on Ubuntu 14.04
How to install Go on Ubuntu 20.04
How to install MongoDB on Ubuntu 16.04
How to install Mailpile on Ubuntu 14.04