拉取 jdk17 的源码

这里准备了一份:https://github.com/susamlu/jdk20240618,branch:jdk-17+35

使用 Linux 编译 jdk17

系统版本:CentOS Linux release 7.9.2009 (Core)

安装 jdk16

  1. wget https://download.java.net/openjdk/jdk16/ri/openjdk-16+36_linu...(可从这里找到:https://jdk.java.net/java-se-ri/16
  2. 解压:tar -zxvf openjdk-16+36_linux-x64_bin.tar.gz
  3. 配置:

    • vim ~/.bash_profile
    • source ~/.bash_profile
    export JAVA_HOME=/home/jdk/jdk-16
    export CLASSPATH=.:${JAVA_HOME}/lib
    export PATH=${JAVA_HOME}/bin:$PATH
  4. 验证:java -version

编译过程

1. bash configure

  1. 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
  2. configure: error: Could not find fontconfig!

    sudo yum install fontconfig-devel -y

2. make clean

3. make all

  1. 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

  1. 配置:

    • 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
  2. 验证版本: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)
  3. 使用代码验证
    测试代码:

    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 JvmTest

    Linux
    /home/jdk
    17-internal
    https://openjdk.java.net/

三穆
1 声望1 粉丝

沉舟侧畔千帆过,病树前头万木春。


« 上一篇
CentOS7编译jdk8

引用和评论

0 条评论