概述
之前用vbuntu编译过,这次用centos编译。
完成编译后的整个虚拟机
链接:https://pan.baidu.com/s/1ux0Mmd-szEINYcsoecRI1g
提取码:1qyu
需要编译的openjdk源码压缩包,后面需要编译的时候也可以去官网下载。
https://download.csdn.net/download/hebian1994/86501160
=====================================
1-安装依赖
yum install -y xrender
yum install -y freetype
yum install -y ccache
yum install -y zip unzip
yum -y install zlib zlib-devel
yum -y install bzip2 bzip2-devel
yum -y install ncurses ncurses-devel
yum -y install readline readline-devel
yum -y install openssl openssl-devel
yum -y install openssl-static
yum -y install xz lzma xz-devel
yum -y install sqlite sqlite-devel
yum -y install gdbm gdbm-devel
yum -y install tk tk-devel
yum -y install libffi-devel
yum -y groupinstall "Development Tools"
yum -y install libXtst-devel libXt-devel libXrender-devel
yum -y install alsa-lib-devel cups-devel libX* gcc gcc-c++ freetype-devel libstdc++-static ant make
yum install pcre-devel
yum install zlib zlib-devel
yum install openssl openssl-devel
yum -y install lrzsz
2-下载CentOS-7-x86_64-Minimal-2207-02.iso,用VMware安装。
CentOS Mirrors List
3-彻底删除原有JDK
rpm -qa | grep openjdk |xargs rpm -e --nodeps
rpm -qa | grep java |xargs rpm -e --nodeps
4-安装openjdk 1.8.0_342
yum install java-1.8.0-openjdk* -y
配置环境变量
vim /etc/profile
#在末尾添加
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.342.b07-1.el7_9.x86_64
JRE_HOME=$JAVA_HOME/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
source /etc/profile
java -version
5-下载openjdk8u42的源码
下载地址:
6-开始编译
mkdir /opt/jdk
cd /opt/jdk
rz
选择下载的源码压缩包,上次后解压,得到openjdk目录
unzip openjdk-8u42-src-b03-14_jul_2022.zip
cd openjdk
chmod +x configure
./configure --with-debug-level=fastdebug --with-boot-jdk=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.342.b07-1.el7_9.x86_64
make clean make images
unset JAVA_HOME
unset CLASSPATH
make all
或者
./configure --with-target-bits=64 --with-boot-jdk=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.342.b07-1.el7_9.x86_64 --with-debug-level=slowdebug --enable-debug-symbols ZIP_DEBUGINFO_FILES=0
make CONF=linux-x86_64-normal-server-slowdebug
如果要用GDB进行调试,必须使用这种slowdebug方式进行编译
==================================================
7-在openjdk的build目录下cd到linux-x86_64-normal-server-fastdebug/jdk/bin, 可以看到熟悉的JDK的目录结构了
在bin目录下编写测试代码即可
cd /opt/jdk/openjdk/build/linux-x86_64-normal-server-fastdebug/jdk/bin
[root@localhost bin]# ./java -version
openjdk version "1.8.0-internal-fastdebug"
OpenJDK Runtime Environment (build 1.8.0-internal-fastdebug-root_2022_08_25_16_54-b00)
OpenJDK 64-Bit Server VM (build 25.40-b25-fastdebug, mixed mode)
vim Test.java
public class Test{ public static void main(String args[]){ System.out.println("hello world!"); } }
[root@localhost bin]# ./javac Test.java
[root@localhost bin]# ./java Test
hello world!
如果你有定制JDK某些类或方法(增删改)的需求,需要在解压后的源码目录下进行修改,源码目录位于:
openjdk/jdk/src/share/
8-更改JDK源码后,进行重新编译
cd /openjdk
./configure --with-debug-level=fastdebug --with-boot-jdk=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.342.b07-1.el7_9.x86_64
make clean make images
最后
以上就是仁爱大白为你收集整理的编译openjdk8==centos7.9编译openjdk8的全部内容,希望文章能够帮你解决编译openjdk8==centos7.9编译openjdk8所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复