OpenJDK13 is the latest and simplest OpenJDK13 code compilation

Recently, I need to check the JVM source code for my article, and sometimes the code logic is not very clear. I took a long time to download OpenJDK13 to build the JVM debug environment while taking advantage of the National Day holiday. I wrote the operation record in this article, so that friends who need it can refer to it and avoid the pits.

I compiled under Ubuntu 18.04, not Windows, and I recommend not to mess around with Windows, which will cause a lot more problems than Linux. If your computer is also Windows, you can do what I did, install VMware VIRTUAL machine software, install Ubuntu system in it, and play in the VIRTUAL machine. These two software can be downloaded from the official website. Of course, if you are too lazy to find it, you can also reply in the background of my official account: You have obtained VMware software and Ubuntu 18.04 images for VMS.

Installing an Ubuntu VIRTUAL machine is beyond the scope of this article, which is available online.

Began to cough up

1. Download source code

Most of the code management tools we use are Git. OpenJDK doesn’t use Mercurial, so we need to install it. Run the following command to install it.

sudo apt-get install mercurial
Copy the code

After installing the code management tool, you can download the source code of OpenJDK13 using the following command. This process takes different time depending on network conditions, but it took me about 10 minutes to download.

hg clone http://hg.openjdk.java.net/jdk/jdk13/
Copy the code

Well, I did this for about ten minutes, because the specific official operation document is also in there, I can’t read it until I download it, and I can’t find the relevant article about Ubuntu 18 compiling OpenJDK13 online, so I don’t know which dependencies to install. Now that you’ve read this article, don’t wait around. Steps 2 and 3 are independent of the source code and can continue.

2. Install and compile dependencies

This part is to view the official document, made a summary, the official document is divided by software, so a command a command to knock a little cumbersome, it is integrated into a command, the execution is over, to meet some friends want to compile as soon as possible, less redundant things.

sudo apt-get install libfreetype6-dev libcups2-dev libx11-dev libxext-dev libxrender-dev libxrandr-dev libxtst-dev libxt-dev libasound2-dev libffi-dev autoconf gcc clang libfontconfig1-dev
Copy the code

To see what these dependencies do, take a look at the official documentation, which is located below.

3. Install JDK 12

For example, if you compile OpenJDK8, you will use JDK7 as the Boot JDK. For example, if you compile OpenJDK8, you will use JDK7 as the Boot JDK. So JDK12 is used. Just execute the following command.

sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-12-jdk
Copy the code

Verify that the installation is successful by using Java -version. Not if you see something like this.

After the above steps, congratulations, you are now ready to compile.

4. Check the configuration

We installed so many things above, we need to check that we have installed the required software, by the following command to check.

bash configure
Copy the code

If there is an exception during execution, install the missing software according to the exception and prompt information. If you see the results below, congratulations again, all dependencies are ready.

5. Start compiling

The most exciting moment has arrived. Type in the following command and start compiling. This process takes about half an hour, and you can wait patiently, take a break, and have a cup of ’82 coffee.

make images
Copy the code

Pictures of miracles. See the following figure for a successful compilation.

6. Check whether the verification is successful

A little more stability is needed to verify that the compiled Java is usable, using the following command.

./build/*/images/jdk/bin/java -version
Copy the code

[/ backcolor] [/ backcolor] [/ backcolor] [/ backcolor] [/ backcolor] [/ backcolor] [/ backcolor] [/ backcolor]

This title is not too much, the above version date is 2019-09-17, less than a month, there is no related information online, only the official document (of course, is the best information). Follow the steps, will not lose, in order to verify this sentence, also put the above steps in my nearly retired notebook ran again, no problem.

review

In this article, we will discuss how to build the Debug JVM environment in OpenJDK13, and we will look forward to the next article.

Recommended reading

The latest and simplest OpenJDK13 code compilation

Understand the Java thread priority, but also the corresponding operating system priority, otherwise you will step on the pit

The most basic knowledge of threads

The boss told you to stop blocking

You can eat fast food and learn serial, parallel, and concurrency

Make a cup of tea and learn asynchrony

How much do we know about the process?

Design patterns seen and forgotten, forgotten and read?

If you reply “Design Mode”, you can get the ebook “One Story one Design Mode”

Think the article is useful to help forward & praise, thank you friends!