1.操作系统
OpenJDK文档对操作系统最低要求:
Operating system | Vendor/version used |
---|---|
Linux | Oracle Enterprise Linux 6.4 / 7.6 |
Solaris | Solaris 11.3 SRU 20 |
macOS | Mac OS X 10.13 (High Sierra) |
Windows | Windows Server 2012 R2 |
这里选择CentOS8.1
项目 | 配置 |
内存 | 8G |
处理器核数 | 4 |
磁盘 | 60G |
网络 | 已联网 |
CentOS8.1国内镜像地址,下载速度杠杠滴
http://ap.stykers.moe/centos/8.1.1911/isos/x86_64/
http://mirrors.neusoft.edu.cn/centos/8.1.1911/isos/x86_64/
http://mirrors.njupt.edu.cn/centos/8.1.1911/isos/x86_64/
http://mirrors.aliyun.com/centos/8.1.1911/isos/x86_64/
http://mirrors.cn99.com/centos/8.1.1911/isos/x86_64/
http://mirrors.huaweicloud.com/centos/8.1.1911/isos/x86_64/
http://mirrors.tuna.tsinghua.edu.cn/centos/8.1.1911/isos/x86_64/
http://mirrors.163.com/centos/8.1.1911/isos/x86_64/
http://ftp.sjtu.edu.cn/centos/8.1.1911/isos/x86_64/
http://mirrors.zju.edu.cn/centos/8.1.1911/isos/x86_64/
http://mirrors.cqu.edu.cn/CentOS/8.1.1911/isos/x86_64/
http://mirrors.nju.edu.cn/centos/8.1.1911/isos/x86_64/
修改dnf/yum源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
cd /etc/yum.repos.d
#备份
cp CentOS-Base.repo CentOS-Base.repo.bak
cp CentOS-AppStream.repo CentOS-AppStream.repo.bak
cp CentOS-Extras.repo CentOS-Extras.repo.bak
sed -i 's/mirrorlist=/#mirrorlist=/g' CentOS-Base.repo CentOS-AppStream.repo CentOS-Extras.repo
sed -i 's/#baseurl=/baseurl=/g' CentOS-Base.repo CentOS-AppStream.repo CentOS-Extras.repo
sed -i 's/http:\/\/mirror.centos.org/https:\/\/mirrors.aliyun.com/g' CentOS-Base.repo CentOS-AppStream.repo CentOS-Extras.repo
2.安装开发者工具包
OpenJDK文档对编译器(工具链)建议要求:
Operating system | Toolchain version |
---|---|
Linux | gcc 8.3.0(最低要求版本为5.0) |
macOS | Apple Xcode 10.1 (using clang 10.0.0) |
Solaris | Oracle Solaris Studio 12.6 (with compiler version 5.15) |
Windows | Microsoft Visual Studio 2017 update 15.9.16 |
这里选择CentOS8.1 的“Development Tools”工具包,其中已包含(满足要求):
gcc-8.3.1-4.5.el8.x86_64
gcc-c++-8.3.1-4.5.el8.x86_64
查看工具包
dnf group list
安装开发者工具包
sudo dnf group install "Development Tools"
被安装的软件清单
Installed:
asciidoc-8.6.10-0.5.20180627gitf7c2274.el8.noarch autoconf-2.69-27.el8.noarch automake-1.16.1-6.el8.noarch
bison-3.0.4-10.el8.x86_64 byacc-1.9.20170709-4.el8.x86_64 ctags-5.8-22.el8.x86_64
diffstat-1.61-7.el8.x86_64 flex-2.6.1-9.el8.x86_64 gcc-8.3.1-4.5.el8.x86_64
gcc-c++-8.3.1-4.5.el8.x86_64 gdb-8.2-6.el8.x86_64 git-2.18.2-1.el8_1.x86_64
intltool-0.51.0-11.el8.noarch jna-4.5.1-5.el8.x86_64 libtool-2.4.6-25.el8.x86_64
ltrace-0.7.91-27.el8.x86_64 patchutils-0.3.4-10.el8.x86_64 perl-Fedora-VSP-0.001-9.el8.noarch
perl-generators-1.10-9.el8.noarch pesign-0.112-25.el8.x86_64 redhat-rpm-config-120-1.el8.noarch
rpm-build-4.14.2-25.el8.x86_64 source-highlight-3.1.8-16.el8.x86_64 systemtap-4.1-6.el8.x86_64
valgrind-1:3.15.0-9.el8.x86_64 valgrind-devel-1:3.15.0-9.el8.x86_64 glibc-devel-2.28-72.el8_1.1.x86_64
make-1:4.2.1-9.el8.x86_64 rpm-sign-4.14.2-25.el8.x86_64 gcc-gdb-plugin-8.3.1-4.5.el8.x86_64
kernel-devel-4.18.0-147.5.1.el8_1.x86_64 annobin-8.78-1.el8.x86_64 boost-filesystem-1.66.0-6.el8.x86_64
boost-timer-1.66.0-6.el8.x86_64 copy-jdk-configs-3.7-1.el8.noarch cpp-8.3.1-4.5.el8.x86_64
docbook-dtds-1.0-69.el8.noarch docbook-style-xsl-1.79.2-7.el8.noarch dwz-0.12-9.el8.x86_64
dyninst-10.1.0-2.el8.x86_64 efi-srpm-macros-3-2.el8.noarch gc-7.6.4-3.el8.x86_64
gdb-headless-8.2-6.el8.x86_64 ghc-srpm-macros-1.4.2-7.el8.noarch git-core-2.18.2-1.el8_1.x86_64
git-core-doc-2.18.2-1.el8_1.noarch go-srpm-macros-2-16.el8.noarch graphviz-2.40.1-39.el8.x86_64
guile-5:2.0.14-7.el8.x86_64 isl-0.16.1-6.el8.x86_64 java-1.8.0-openjdk-headless-1:1.8.0.242.b08-0.el8_1.x86_64
javapackages-filesystem-5.3.0-1.module_el8.0.0+11+5b8c10bd.noarch libXaw-1.0.13-10.el8.x86_64 libatomic_ops-7.6.2-3.el8.x86_64
libbabeltrace-1.5.4-2.el8.x86_64 libipt-1.6.1-8.el8.x86_64 libstdc++-devel-8.3.1-4.5.el8.x86_64
nss-tools-3.44.0-8.el8.x86_64 ocaml-srpm-macros-5-4.el8.noarch openblas-srpm-macros-2-2.el8.noarch
perl-Error-1:0.17025-2.el8.noarch perl-Git-2.18.2-1.el8_1.noarch perl-TermReadKey-2.37-7.el8.x86_64
perl-Thread-Queue-3.13-1.el8.noarch perl-XML-Parser-2.44-11.el8.x86_64 perl-srpm-macros-1-25.el8.noarch
python-srpm-macros-3-37.el8.noarch python3-rpm-macros-3-37.el8.noarch qt5-srpm-macros-5.11.1-2.el8.noarch
rust-srpm-macros-5-2.el8.noarch systemtap-client-4.1-6.el8.x86_64 systemtap-devel-4.1-6.el8.x86_64
systemtap-runtime-4.1-6.el8.x86_64 tbb-2018.2-9.el8.x86_64 tzdata-java-2019c-1.el8.noarch
xorg-x11-fonts-ISO8859-1-100dpi-7.5-19.el8.noarch elfutils-0.176-5.el8.x86_64 gettext-common-devel-0.19.8.1-17.el8.noarch
gettext-devel-0.19.8.1-17.el8.x86_64 glibc-headers-2.28-72.el8_1.1.x86_64 kernel-headers-4.18.0-147.5.1.el8_1.x86_64
libxcrypt-devel-4.1.1-4.el8.x86_64 lksctp-tools-1.0.18-3.el8.x86_64 m4-1.4.18-7.el8.x86_64
mokutil-1:0.3.0-9.el8.x86_64 patch-2.7.6-9.el8_0.x86_64 sgml-common-0.6.3-50.el8.noarch
3.Boot JDK
OpenJDK文档对Boot JDK建议要求:N-1
这里选择 JDK 13.0.2版本
下载地址:https://www.oracle.com/java/technologies/javase-jdk13-downloads.html
4.扩展包需求
OpenJDK文档对External Library建议要求
不同的平台需要不同的扩展库。一般来说,库是不可选的——也就是说,它们要么是必需的,要么是不被使用的。如果configure没有检测到所需的库,则需要提供它的路径。有两种形式的配置参数指向扩展库:--with-
FreeType
sudo yum install freetype-devel
CUPS
sudo yum install cups-devel
X11
sudo yum install libXtst-devel libXt-devel libXrender-devel libXrandr-devel libXi-devel.
ALSA
sudo yum install alsa-lib-devel
libffi
sudo yum install libffi-devel
5.构建工具
OpenJDK文档对构建工具建议要求
构建工具名称 | 平台 | 最低版本 |
Autoconf | 所有 | 2.69 |
GNU Make | 所有 | 3.81 |
GNU Bash | 所有 | 3.2 |
安装命令
sudo yum install autoconf
Make 和 Bash在上面的开发者工具包中已安装,这里不再赘述。
git clone https://github.com/unofficial-openjdk/openjdk.git
cd openjdk
./configure --with-boot-jdk=/opt/jdk-13.0.2
make JOBS=6
在Linux上,可以选择c++运行时的静态或动态链接,默认是静态链接,如果没有找到静态库,则使用动态链接作为后备,使用方法是增加以下配置:
--with-stdc++lib=dynamic --使用指定的方法(static、dynamic或default)链接c++运行时
执行./configure 成功后输出的内容:
====================================================
A new configuration has been successfully created in
/opt/openjdk14/build/linux-x86_64-server-release
using configure arguments '--with-boot-jdk=/opt/jdk-13.0.2'.
Configuration summary:
* Debug level: release
* HS debug level: product
* JVM variants: server
* JVM features: server: 'aot cds compiler1 compiler2 epsilongc g1gc graal jfr jni-check jvmci jvmti management nmt parallelgc serialgc services shenandoahgc vm-structs zgc'
* OpenJDK target: OS: linux, CPU architecture: x86, address length: 64
* Version string: 15-internal+0-adhoc.root.openjdk14 (15-internal)
Tools summary:
* Boot JDK: java version "13.0.2" 2020-01-14 Java(TM) SE Runtime Environment (build 13.0.2+8) Java HotSpot(TM) 64-Bit Server VM (build 13.0.2+8, mixed mode, sharing) (at /opt/jdk-13.0.2)
* Toolchain: gcc (GNU Compiler Collection)
* C Compiler: Version 8.3.1 (at /usr/bin/gcc)
* C++ Compiler: Version 8.3.1 (at /usr/bin/g++)
Build performance summary:
* Cores to use: 4
* Memory limit: 7789 MB
执行make JOBS=6成功后输出的内容:
Compiling 4 files for BUILD_JIGSAW_TOOLS
Optimizing the exploded image
Finished building target 'default (exploded-image)' in configuration 'linux-x86_64-server-release'
进入build的目录验证编译成果:
cd build
## linux-x86_64-server-release 是默认编译输出的版本
cd linux-x86_64-server-release/jdk/bin
./java -version
执行./java -version后输出:
openjdk version "15-internal" 2020-09-15
OpenJDK Runtime Environment (build 15-internal+0-adhoc.root.openjdk14)
OpenJDK 64-Bit Server VM (build 15-internal+0-adhoc.root.openjdk14, mixed mode)