Edit OpenJDK11 source code in Ubuntu environment

   Copyright statement: welcome to reprint, please indicate the source, thank you. https://blog.csdn.net/boling_cavalry/article/details/83303317

Ready to work###

  1. The Ubuntu version is 16.04.5 LTS;
  2. Confirm that the OpenJDK11 source code has been downloaded locally. For the download method, please refer to the article "Download OpenJDK11 Source Code in Ubuntu Environment", "Download OpenJDK11 Source Code Using Docker Fast";
  3. Install OpenJDK10 as the boot JDK. For the installation process, please refer to the article "Installing OpenJDK10 under Ubuntu";

The location of important folders###

  1. After the OpenJDK11 source code is decompressed, it is a folder named jdk11, located in this directory: /home/willzhao/work/compileopenjdk
  2. After OpenJDK10 is installed, it is a folder named jdk-10 as a whole, located in this directory: /usr/lib/jvm, so the complete directory of boot JDK is /usr/lib/jvm/jdk-10

The above is the file path on my side, if you are inconsistent with mine, it doesn’t matter, please pay attention to modify it to your own corresponding;

Officially begin###

  1. When compiling, the lib library in the jre directory of boot JDK will be used. We only have JDK without jre here, so we need to create a jre directory, then copy the lib folder of jdk to this directory, and execute the following command:
mkdir /usr/lib/jvm/jdk-10/jre && cp -r /usr/lib/jvm/jdk-10/lib /usr/lib/jvm/jdk-10/jre/
  1. I used the root account, so I changed the owner and user group of the OpenJDK11 source code folder to root, and executed the following command in the directory /home/willzhao/work/compileopenjdk:
chown -R root jdk11 && chgrp -R root jdk11
  1. Install the necessary dependent applications:
apt-get install -y autoconf zip libx11-dev libxext-dev libxrender-dev libxtst-dev libxt-dev libcups2-dev libfontconfig1-dev libasound2-dev
  1. Enter the directory of the OpenJDK11 source code /home/willzhao/work/compileopenjdk/jdk11
  2. After the configuration is confirmed, you can start to compile after this step is passed:
bash configure --with-num-cores=4--with-memory-size=8192

In the above command, –with-num-cores=4 means quad-core CPU participates in compilation, –with-memory-size=8192 means 8G memory participates in compilation, please adjust according to the actual configuration of your computer;
If the configuration fails, there will be related prompts, please make adjustments according to the prompt content. The applications installed in step 3 are actually prompted to be installed when the configuration check fails;

  1. After the configuration is confirmed, the console prompt information is roughly as follows:
====================================================
A newconfiguration has been successfully created in/home/willzhao/work/compileopenjdk/jdk11/build/linux-x86_64-normal-server-release
using configure arguments '--with-num-cores=4 --with-memory-size=8192'.

Configuration summary:* Debug level:    release
* HS debug level: product
* JVM variants:   server
* JVM features:   server:'aot cds cmsgc compiler1 compiler2 epsilongc g1gc graal jfr jni-check jvmci jvmti management nmt parallelgc serialgc services vm-structs'* OpenJDK target: OS: linux, CPU architecture: x86, address length:64* Version string:11-internal+0-adhoc.root.jdk11(11-internal)

Tools summary:* Boot JDK:       openjdk version "10"2018-03-20 OpenJDK Runtime Environment 18.3(build 10+44) OpenJDK 64-Bit Server VM 18.3(build 10+44, mixed mode)(at /usr/lib/jvm/jdk-10)* Toolchain:gcc(GNU Compiler Collection)* C Compiler:     Version 5.4.0(at /usr/bin/gcc)* C++ Compiler:   Version 5.4.0(at /usr/bin/g++)

Build performance summary:* Cores to use:4* Memory limit:8192 MB
  1. Execute the command make to start the compilation, and wait for the console to output the following similar information after the compilation is completed:
Creating support/modules_cmds/jdk.pack/pack200 from1file(s)
Creating support/modules_cmds/jdk.pack/unpack200 from7file(s)
Creating support/modules_cmds/jdk.rmic/rmic from1file(s)
Creating support/modules_cmds/jdk.scripting.nashorn.shell/jjs from1file(s)
Creating support/modules_libs/jdk.sctp/libsctp.so from3file(s)
Creating support/modules_libs/jdk.security.auth/libjaas.so from1file(s)
Compiling 4 files for BUILD_JIGSAW_TOOLS
Stopping sjavac server
Finished building target 'default (exploded-image)'in configuration 'linux-x86_64-normal-server-release'
  1. Open the build.log file in the jdk11/build/linux-x86_64-normal-server-release directory to see a more detailed log:
Creating support/modules_cmds/jdk.pack/unpack200 from7file(s)
Creating support/modules_cmds/jdk.rmic/rmic from1file(s)
Creating support/modules_cmds/jdk.scripting.nashorn.shell/jjs from1file(s)
Creating support/modules_libs/jdk.sctp/libsctp.so from3file(s)
Creating support/modules_libs/jdk.security.auth/libjaas.so from1file(s)
Compiling 4 files for BUILD_JIGSAW_TOOLS
- - - - - Build times -------
Start 2018-10-2314:45:20
End   2018-10-2314:53:5300:08:33 TOTAL
-------------------------
Finished building target 'default (exploded-image)'in configuration 'linux-x86_64-normal-server-release'
  1. In the jdk11/build/linux-x86_64-normal-server-release directory, there is a jdk directory, which is the newly built OpenJDK, enter the bin directory inside, and then execute the command ./java -version, you can see the latest version information As follows, it is already version 11:
root@willzhao-Lenovo-Ubuntu16:/home/willzhao/work/compileopenjdk/jdk11/build/linux-x86_64-normal-server-release/jdk/bin# ./java -version
openjdk version "11-internal"2018-09-25
OpenJDK Runtime Environment(build 11-internal+0-adhoc.root.jdk11)
OpenJDK 64-Bit Server VM(build 11-internal+0-adhoc.root.jdk11, mixed mode)

At this point, the compilation and construction based on the OpenJDK11 source code has been successful, and the new JDK can be used normally by setting the environment variables in the /etc/profile file;

Recommended Posts

Edit OpenJDK11 source code in Ubuntu environment
Download OpenJDK11 source code in Ubuntu environment
How to compile and install xdebug from source code in Ubuntu environment
Compile and install OpenJDK8 from source code under Ubuntu 18.04.1
Android source code compilation (ubuntu16.04 64-bit)
How to easily compile openJDK in Ubuntu
Configure Java development environment in Ubuntu20.04 LTS
About installing node environment in Ubuntu server
How to modify software source in Ubuntu 7.10
Ubuntu 18.04 install Odoo14 tutorial through source code
Docker those things in the Ubuntu environment
How to configure TensorFlow use environment in Ubuntu
Install Python3 environment in a brand new Ubuntu
Remotely connect to MySQL database in Ubuntu environment
Installation and use of SSH in Ubuntu environment
ubuntu replacement source
Installation and simple practice of MySQL in ubuntu environment (1)
How to create a Python virtual environment in Ubuntu 14.04
Tutorial for setting up FTP server in Ubuntu 16.04 environment
Resolve the problems encountered in the linux environment under ubuntu
Install mysql-pytho in Ubuntu
Nagios3 in ubuntu serve
Ubuntu update software source
Install OpenJDK10 under Ubuntu
Ubuntu configuration development environment
Use supervisor in ubuntu
Ubuntu make offline source
Ubuntu development environment configuration
Ubuntu Touch environment setup
Install python in Ubuntu
Install JDK in Ubuntu19.10
Ubuntu18.10 configure Java environment
ubuntu environment deployment project
How to install memcache and start it in ubuntu environment
Encountered in the process of building a virtual environment in ubuntu
Detailed steps for installing Django under Python 3.6 in Ubuntu 16.04 environment
How to compile and install PHP and Nginx in Ubuntu environment