zoukankan      html  css  js  c++  java
  • Ubuntu18编译openjdk11

    在Ubuntu下编译openjdk11

    建议在配置环境的各个环节过程中拍摄快照

    在此附上openjdk10/11的源码链接:

    https://pan.baidu.com/s/15Q6axYE8aViUHSZGF9Iecg
    提取码:hnip

    1. Ubuntu版本信息

    Ubuntu 18.04.4 LTS
    
    1. 编译openjdk11前需要一个Bootstrap JDK

    一般情况下,编译Openjdk11时,需要前置JDk即Bootstrap JDK来编译当前需要编译的JDK,

    一般选择,当前编译JDK版本之后的JDK,这里编译Openjdk11,选择Openjdk10作为Bootstrap JDK

    # 上传并解压后为 jdk-10
    tar -zxvf /usr/lib/jvm/openjdk-10+44_linux-x64_bin_ri.tar.gz
    
    # 配置环境变量
    sudo vim /etc/profile
    
    # 配置信息如下
    export JAVA_HOME=/usr/lib/jvm/jdk-10
    export JRE_HOME=${JAVA_HOME}/jre
    export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
    export PATH=${JAVA_HOME}/bin:$PATH
    
    # 刷新配置文件使其生效
    source /etc/profile
    
    
    1. 配置编译环境

    编译的时候会用到Bootstrap JDK的jre目录下的lib库,这里只有JDK没有jre,因此需要创建一个jre目录,再把jdk的lib文件夹复制到jre目录下,执行以下命令:

    mkdir /usr/lib/jvm/jdk-10/jre && cp -r /usr/lib/jvm/jdk-10/lib /usr/lib/jvm/jdk-10/jre/
    
    1. 上传openjdk11至Ubuntu

    # 上传并解压
    unzip /usr/local/jason/openjdk/openjdk11-master.zip
    
    # 修改名称为 jdk11
    $ mv openjdk11-master jdk11
    
    # 进入/usr/local/jason/openjdk目录
    # 修改jdk11权限为root用户
    chown -R root jdk11 && chgrp -R root jdk11
    
    1. 安装编译所需软件

    sudo apt-get install libfreetype6-dev
    sudo apt-get install autoconf
    sudo apt-get install libffi-dev
    sudo apt-get install libasound2-dev
    sudo apt-get install libx11-dev libxext-dev libxrender-dev libxtst-dev libxt-dev libxrandr-dev
    sudo apt-get install  libfontconfig1-dev
    sudo apt-get install  libcups2-dev
    
    1. 进入jdk11检查编译环境

    # 进入jdk11目录
    sudo bash configure
    
    # 有如下信息则配置完成
    A new configuration has been successfully created in
    /usr/local/jason/openjdk/jdk11/build/linux-x86_64-normal-server-release
    using default settings.
    
    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 7.5.0 (at /usr/bin/gcc)
    * C++ Compiler:   Version 7.5.0 (at /usr/bin/g++)
    
    Build performance summary:
    * Cores to use:   1
    * Memory limit:   1958 MB
    
    1. 按照指定条件生成配置

    # –with-num-cores=8表示八核CPU参与编译
    # --with-memory-size=8192表示8G内存参与编译
    # --disable-warnings-as-errors忽略警告,直至编译完成。
    sudo bash configure --with-num-cores=4 --with-memory-size=8192 --disable-warnings-as-errors
    
    1. 开始编译

    sudo make 
    
    # 漫长的等待……
    
    Finished building target 'default (exploded-image)' in configuration 'linux-x86_64-normal-server-release'
    
    1. 查看编译结果

    # 进入下方目录
    cd /usr/local/jason/openjdk/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)
    
  • 相关阅读:
    微软外服 AlI In One
    js 循环多次和循环一次的时间的性能对比 All In One
    vue inject All In One
    Excel 表格数据倒置 All In One
    SVG tickets All In One
    OH MY ZSH All In One
    js array for loop performance compare All In One
    mac terminal show You have new mail All In one
    新闻视频 26 制作母版页
    转自牛腩 母版页和相对路径
  • 原文地址:https://www.cnblogs.com/code-duck/p/13462718.html
Copyright © 2011-2022 走看看