拉取 jdk17 的源码
这里准备了一份:https://github.com/susamlu/jdk20240618,branch:jdk-17+35
使用 Linux 编译 jdk17
系统版本:CentOS Linux release 7.9.2009 (Core)
安装 jdk16
- wget https://download.java.net/openjdk/jdk16/ri/openjdk-16+36_linu...(可从这里找到:https://jdk.java.net/java-se-ri/16)
- 解压:tar -zxvf openjdk-16+36_linux-x64_bin.tar.gz
配置:
- vim ~/.bash_profile
- source ~/.bash_profile
export JAVA_HOME=/home/jdk/jdk-16 export CLASSPATH=.:${JAVA_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
- 验证:java -version
编译过程
1. bash configure
configure: error: Could not find all X11 headers (shape.h Xrender.h Xrandr.h XTest.h Intrinsic.h).
sudo yum install libXtst-devel libXt-devel libXrender-devel libXrandr-devel libXi-devel -y
configure: error: Could not find fontconfig!
sudo yum install fontconfig-devel -y
2. make clean
3. make all
gcc: error: unrecognized command line option '-std=c++14'
sudo yum install centos-release-scl -y sudo yum install devtoolset-7 -y sudo scl enable devtoolset-7 bash
重新运行 bash configure、make clean,再运行 make all
编译需要点时间,需要耐心等待......
编译成功,就可以测试了
测试 jdk17
配置:
- vim ~/.bash_profile
- source ~/.bash_profile
export JAVA_HOME=/home/jdk/jdk/build/linux-x86_64-server-release/images/jdk export CLASSPATH=.:${JAVA_HOME}/lib export PATH=${JAVA_HOME}/bin:$PATH
验证版本:java -version
openjdk version "17-internal" 2021-09-14 OpenJDK Runtime Environment (build 17-internal+0-adhoc.root.jdk) OpenJDK 64-Bit Server VM (build 17-internal+0-adhoc.root.jdk, mixed mode, sharing)
使用代码验证
测试代码:public class JvmTest { public static void main(String[] args) { System.out.println(System.getProperty("os.name")); System.out.println(System.getProperty("user.home")); System.out.println(System.getProperty("java.version")); System.out.println(System.getProperty("java.vendor.url")); } }
javac JvmTest.java
java JvmTestLinux /home/jdk 17-internal https://openjdk.java.net/
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。