ubuntu20.04编译openjdk8

  • Post author:
  • Post category:其他


1. 下载jdk1.7


Java Archive Downloads – Java SE 7

解压tar -xvzf,移动到/usr/lib/jvm/下

2、hg clone

http://hg.openjdk.java.net/jdk8u/jdk8u-dev;cd

jdk8u-dev;sh get_source.sh

3、添加环境变量

export LANG=C

export PATH=”/usr/lib/jvm/jdk1.7.0_80/bin:${PATH}”

4、bash ./configure

报错configure: error: Could not find all X11 headers (shape.h Xrender.h XTest.h Intrinsic.h). You might be able to fix this by running ‘sudo apt-get install libX11-dev libxext-dev libxrender-dev libxtst-dev libxt-dev’.

configure exiting with result code 1

安装缺少的依赖包

sudo apt-get install libx11-dev libxext-dev libxrender-dev libxtst-dev libxt-dev

重新bash ./configure

报错configure: error: Could not find cups! You might be able to fix this by running ‘sudo apt-get install libcups2-dev’

安装sudo apt-get install libcups2-dev

重新bash ./configure

报错configure: error: Could not find freetype! You might be able to fix this by running ‘sudo apt-get install libfreetype6-dev’

安装sudo apt-get install libfreetype6-dev

重新bash ./configure

报错configure: error: Could not find alsa! You might be able to fix this by running ‘sudo apt-get install libasound2-dev’

安装sudo apt-get install libasound2-dev

重新bash ./configure

configure: error: Could not find fontconfig! You might be able to fix this by running ‘sudo apt-get install libfontconfig1-dev’.

configure exiting with result code 1

安装 sudo apt-get install libfontconfig1-dev

重新bash ./configure

/home/wl/openjdk8/jdk8u-dev/hotspot/src/os/linux/vm/os_linux.cpp:4993:15: error: ‘%s’ directive argument is null [-Werror=format-overflow=]

4993 |     tty->print(“Warning: %s handler “, exception_name(sig, buf, O_BUFLEN));

|     ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

cc1plus: all warnings being treated as errors

make[6]: *** [/home/wl/openjdk8/jdk8u-dev/hotspot/make/linux/makefiles/rules.make:151: os_linux.o] Error 1

添加

–with-extra-cflags=-Wno-error

–with-extra-cxxflags=-Wno-error

5、make all

6、编译成功后,在/home/wl/openjdk/jdk8u-dev/build/linux-x86_64-normal-server-release/images/j2sdk-image/bin目录下,运行./java -version,输出

openjdk version “1.8.0-internal”

OpenJDK Runtime Environment (build 1.8.0-internal-l_2017_12_03_07_32-b00)

OpenJDK 64-Bit Server VM (build 25.71-b00, mixed mode)



版权声明:本文为wuli2496原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。