`

How to build and package OpenJDK 7 on Linux

 
阅读更多

Some pre-requisites are required to build OpenJDK7 on Linux

Build and package pre-requisites

Be sure to have git, mercurial, gcc/g++, make and required libs and some mandatory tools installed. Java 6 or 7 should be installed.

Ensure JAVA_HOME env var point to a valid JDK location, example for openSUSE 12.2 :

echo $JAVA_HOME
/usr/lib64/jvm/java

Ubuntu 12.x-13.x / Mint 14-16

sudo apt-get install git mercurial zip bzip2 unzip tar gawk
sudo apt-get install ccache make gcc g++ ca-certificates ca-certificates-java
sudo apt-get install libX11-dev libxext-dev libxrender-dev libxtst-dev  
sudo apt-get install libasound2-dev libcups2-dev libfreetype6-dev
sudo apt-get install build-essential ruby-dev
sudo apt-get install openjdk-7-jdk
sudo gem install fpm

openSUSE / SLES

sudo zypper install git-core mercurial zip bzip2 unzip tar 
sudo zypper install autoconf ccache make gcc gcc-c++ ca-certificates-cacert ca-certificates-mozilla
sudo zypper install libstdc++-devel alsa-devel cups-devel xorg-x11-devel libjpeg62-devel giflib-devel 
sudo zypper install curl rpm-build gpg
sudo zypper install java-1_6_0-openjdk-devel (or java-1_7_0-openjdk-devel)

CentOS 5/6

On CentOS 5, You should have EPEL installed :

sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

Needed packages :

sudo yum install git-core mercurial zip bzip2 unzip tar 
sudo yum install autoconf ccache make gcc gcc-c++ libstdc++-devel 
sudo yum install alsa-lib-devel cups-devel fontconfig-devel libX11-devel libXext-devel libXt-devel libXrender-devel libXtst-devel libXi-devel libjpeg-devel giflib-devel freetype-devel
sudo yum install curl rpm-build gpg
sudo yum install java-1.6.0-openjdk-devel (or java-1.7.0-openjdk-devel)

Fedora 17/18

sudo yum install git-core mercurial zip bzip2 unzip tar 
sudo yum install autoconf ccache make gcc gcc-c++ 
sudo yum install libstdc++-devel libstdc++-static alsa-lib-devel cups-devel fontconfig-devel libX11-devel libXext-devel libXt-devel libXrender-devel libXtst-devel libXi-devel libjpeg-devel giflib-devel freetype-devel 
sudo yum install curl rpm-build gpg rpmbuild rpm-sign
sudo yum install java-1.7.0-openjdk-devel

Prepare environment

For example, you want to build OpenJDKs in openjdkathome directory under your home directory.

mkdir ~/openjdkathome
cd ~/openjdkathome
git clone https://github.com/hgomez/obuildfactory.git

Building OpenJDK

Building is activated by XBUILD env var set to true

cd ~/openjdkathome
XBUILD=true ./obuildfactory/openjdk7/linux/standalone-job.sh

After some minutes you should see this logs :

#-- Build times ----------
Target all_product_build
Start 2012-11-09 16:33:27
End   2012-11-09 17:46:09
00:04:46 corba
00:29:46 hotspot
00:00:41 jaxp
00:00:53 jaxws
00:35:09 jdk
00:01:27 langtools
01:12:42 TOTAL
-------------------------
make[1]: Leaving directory `/root/openjdkathome/sources/openjdk7'
openjdk version "1.7.0-u12-b01"
OpenJDK Runtime Environment (build 1.7.0-u12-b01-20121109)
OpenJDK 64-Bit Server VM (build 24.0-b24, mixed mode)
openjdk version "1.7.0-u12-b01"
OpenJDK Runtime Environment (build 1.7.0-u12-b01-20121109)
OpenJDK 64-Bit Server VM (build 24.0-b24, mixed mode)

You'll find JDK/JRE tarballs under OBF_DROP_DIR/openjdk7

ls -l OBF_DROP_DIR/openjdk7
total 276092
-rw-r--r-- 1 root root 124458037 Nov  9 17:47 j2re-image-x86_64-u12-b01-20121109.tar.bz2
-rw-r--r-- 1 root root 157968523 Nov  9 17:47 j2sdk-image-x86_64-u12-b01-20121109.tar.bz2

Images tarballs

Images tarballs could be used like any others Unix Java, ie :

mbp-rico:openjdkathome henri$ tar xvfj OBF_DROP_DIR/openjdk7/j2sdk-image-x86_64-u12-b01-20121109.tar.bz2
x j2sdk-image/
x j2sdk-image/ASSEMBLY_EXCEPTION
x j2sdk-image/bin/
x j2sdk-image/demo/
x j2sdk-image/include/
x j2sdk-image/jre/
x j2sdk-image/lib/
x j2sdk-image/LICENSE
x j2sdk-image/man/
...
x j2sdk-image/bin/tnameserv
x j2sdk-image/bin/unpack200
x j2sdk-image/bin/wsgen
x j2sdk-image/bin/wsimport
x j2sdk-image/bin/xjc

opensuse-rico:openjdkathome henri$ ./j2sdk-image/bin/java -version
openjdk version "1.7.0-u12-b01"
OpenJDK Runtime Environment (build 1.7.0-u12-b01-20121109)
OpenJDK 64-Bit Server VM (build 24.0-b24, mixed mode)

Packaging OpenJDK

Packaging is activated by XPACKAGE env var set to true.

For now, only RPM packaging is supported (DEB contributions welcomed).

cd ~/openjdkathome
XBUILD=true XPACKAGE=true ./obuildfactory/openjdk7/linux/standalone-job.sh

RPM files are located under OBF_DROP_DIR/openjdk7/RPMS/

opensuse-rico:~/openjdkathome # ls -l OBF_DROP_DIR/openjdk7/RPMS/x86_64/
total 74872
-rw-r--r-- 1 root root 30855929 Nov  9 18:32 jdk-1.7.0-openjdk-x86_64-1.7.0.u12.b01-1.x86_64.rpm
-rw-r--r-- 1 root root    12951 Nov  9 18:32 jdk-1.7.0-openjdk-x86_64-db-1.7.0.u12.b01-1.x86_64.rpm
-rw-r--r-- 1 root root  1897421 Nov  9 18:32 jdk-1.7.0-openjdk-x86_64-demo-1.7.0.u12.b01-1.x86_64.rpm
-rw-r--r-- 1 root root   371827 Nov  9 18:32 jdk-1.7.0-openjdk-x86_64-sample-1.7.0.u12.b01-1.x86_64.rpm
-rw-r--r-- 1 root root 20661616 Nov  9 18:32 jdk-1.7.0-openjdk-x86_64-src-1.7.0.u12.b01-1.x86_64.rpm
-rw-r--r-- 1 root root 22755469 Nov  9 18:32 jre-1.7.0-openjdk-x86_64-1.7.0.u12.b01-1.x86_64.rpm

OpenJDK7 will be installer under /opt/obuildfactory/jdk-1.7.0-openjdk-x86_64 or /opt/obuildfactory/jdk-1.7.0-openjdk-i586

To test newly installed OpenJDK, set PATH

opensuse-rico:openjdkathome henri$ export PATH=/opt/obuildfactory/jdk-1.7.0-openjdk-x86_64/bin:$PATH
opensuse-rico:openjdkathome henri$ java -version
openjdk version "1.7.0-u12-b01"
OpenJDK Runtime Environment (build 1.7.0-u12-b01-20121109)
OpenJDK 64-Bit Server VM (build 24.0-b24, mixed mode)

Debug mode

OpenJDK could be built with debug mode, called fast-debug.

In this mode JVM will provide much more informations via flags like -XX:+UnlockDiagnosticVMOptions -XX:+PrintAssembly

To active debug mode, set XDEBUG to true ie :

cd ~/openjdkathome
XDEBUG=true XBUILD=true XPACKAGE=true ./obuildfactory/openjdk7/linux/standalone-job.sh

Debug Tarballs, RPMs will contains fastdebug :

ls -l OBF_DROP_DIR/openjdk7
total 276092
-rw-r--r-- 1 root root 124458037 Nov  9 17:47 j2re-image-fastdebug-x86_64-u12-b01-20121109.tar.bz2
-rw-r--r-- 1 root root 157968523 Nov  9 17:47 j2sdk-image-fastdebug-x86_64-u12-b01-20121109.tar.bz2

Clean vs Incremental build

By default, build are performed in incremental mode, ie only updated code is recompiled, reducing overall build time.

But experience in OpenJDK show that weird things happens sometimes and it's better to start from scratch and perform a clean build.

To activate clean mode, use XCLEAN env var ie :

cd ~/openjdkathome
XCLEAN=true XBUILD=true XPACKAGE=true ./obuildfactory/openjdk7/linux/standalone-job.sh

 

分享到:
评论

相关推荐

    openjdk7ForLinux.zip

    对于压缩包"openjdk7ForLinux",虽然名字提及是zip格式,但通常在Ubuntu中,我们并不直接处理这样的压缩文件,因为apt-get已经为我们提供了安装OpenJDK7的便利。如果该压缩包包含的是手动安装或特定配置的OpenJDK7,...

    openjdk 17.01 linux版本 解压安装包

    在Linux平台上安装OpenJDK 17.0.1是一个常见的任务,尤其对于开发者来说,它是编写、测试和运行Java应用程序的基础。 **1. 下载OpenJDK 17.0.1** 首先,你需要访问OpenJDK的官方网站或者第三方镜像站点下载适用于...

    openjdk 19 linux版本 解压安装包

    OpenJDK 19是Java Development Kit的一个开源实现,它为Linux操作系统提供了Java运行环境和开发工具。在本文中,我们将深入探讨如何在Linux系统上解压并安装OpenJDK 19。首先,让我们了解OpenJDK及其与JDK的关系。 ...

    openjdk-17 GA(openjdk-17_linux-aarch64_bin.tar.gz)

    OpenJDK 17 GA(General Availability)是Java开发工具包的一个重要版本,专为Linux aarch64架构设计。这个版本的发布标志着OpenJDK社区对于Java开发和运行环境的持续优化,尤其是对64位ARM(aarch64)平台的支持。...

    How-to-install-openjdk-on-ubuntu.rar_Ubuntu!_openjdk

    在Ubuntu系统上安装OpenJDK的详细步骤 OpenJDK(Open Java Development Kit)是Java开发工具包的一个开源实现,它提供了运行Java应用程序所需的环境。对于开发者和系统管理员来说,安装OpenJDK在Ubuntu上是相当简单...

    java-openjdk1.8-linux.tar.gz

    Java OpenJDK 1.8 for Linux 是一个广泛使用的Java开发和运行环境,尤其在CentOS 7.5操作系统上。这个版本的JDK(Java Development Kit)是Oracle公司发布的一个开源实现,它包含了编译、调试、运行Java应用程序所需...

    linux下的JDK(java-1.7.0-openjdk-amd64和jdk-7u79-linux-x64)

    本文将详细介绍两个不同版本的JDK——`java-1.7.0-openjdk-amd64`和`jdk-7u79-linux-x64`,并探讨它们的异同以及在Linux环境中的安装与使用。 首先,`java-1.7.0-openjdk-amd64`是OpenJDK的AMD64架构版本,OpenJDK...

    openjdk 18 linux版本 解压安装包

    Linux平台上的OpenJDK 18安装包提供了在Linux操作系统上运行和开发Java应用的基础。在这个解压安装过程中,我们将探讨几个关键的知识点,包括OpenJDK的基本概念、版本18的新特性、安装步骤以及配置环境变量。 1. **...

    OpenJDK 8_322 linux 解压安装版

    OpenJDK 8_322 是一个针对Linux平台的Java开发工具包(JDK)的版本,它在2022年2月进行了更新。OpenJDK是Java Development Kit的开源实现,由OpenJDK社区维护,是Oracle JDK的一个重要分支。这个版本号8u322-b06表示...

    openjdk-18 GA (openjdk-18_linux-x64_bin.tar.gz)

    《OpenJDK 18:深入理解其在Linux x64平台上的应用》 OpenJDK,全称为Open Source Java Development Kit,是Java开发工具集的开源实现,它提供了Java平台标准版(Java SE)的实现。OpenJDK 18是这个项目的一个重要...

    ubuntu下openjdk7 openjdk8

    OpenJDK7和OpenJDK8是两个不同的版本,分别对应Java 7和Java 8。这两个版本在Ubuntu中的安装、配置和使用是本文的重点。 首先,我们来了解OpenJDK7。OpenJDK7是Java SE 7的开源实现,它包含了JVM、Java类库以及Java...

    openjdk8-11-17, linux

    标题“openjdk8-11-17, linux”指的是OpenJDK的特定版本8更新17(8u17)在Linux操作系统上的实现。OpenJDK是Java Development Kit(JDK)的一个开源实现,它是Java编程语言和平台的基础。这个版本号结构中的“8u17”...

    linux java7 jdk+openjdk

    本文将深入探讨“Linux Java7 JDK+OpenJDK”的相关知识点,以及它们在Ubuntu系统上编译Android L/M/N/O版本时的重要性。 首先,Java Development Kit (JDK) 是Java编程语言的核心组件,它包含了开发和运行Java应用...

    openjdk11-linux和windows版本.rar

    此压缩包包含了针对Linux和Windows操作系统的OpenJDK 11的解压版,分别是"openjdk-11+28_linux-x64_bin.tar.gz"和"openjdk-11+28_windows-x64_bin.zip"。这两个文件都是官方版本,但下载可能因网络问题而较慢。 **...

    openjdk 17 for linux

    openjdk 17 for linux

    openjdk 11.02 linux版本 解压安装包

    在Linux环境下安装OpenJDK 11.0.2,首先需要下载对应的压缩包,这里我们讨论的是文件名为“jdk-11.0.2”的安装包。下面将详细阐述如何解压和安装这个版本的OpenJDK。 一、下载OpenJDK 11.0.2 在Linux系统中,你可以...

    openjdk-20-linux-x64-bin.tar.gz

    标题中的"openjdk-20-linux-x64-bin.tar.gz"表明这是一个针对64位Linux系统的OpenJDK 20版本的二进制发行包。OpenJDK的版本号20意味着它是基于Java开发工具集(JDK)的第20个主要版本。每个主要版本通常会引入新的...

    openjdk-11.0.1_linux-x64_bin.tar.gz

    《OpenJDK 11.0.1 for Linux x64 深度解析》 OpenJDK(Open Source Java Development Kit)是Java平台标准版(Java SE)的一个开源实现,由甲骨文公司(Oracle)主导开发并维护。本文将深入探讨OpenJDK 11.0.1在...

    OpenJdk-7.zip

    总之,OpenJDK-7是Ubuntu环境下进行Java开发的重要工具,其 Deb 包的安装使得在Linux系统中部署和使用Java环境变得简单易行。通过了解和掌握OpenJDK-7的安装、组件以及使用方法,开发者可以更好地利用Java进行软件...

    openjdk-11.0.2_linux-x64_bin.zip

    《OpenJDK 11.0.2 Linux-x64 安装与使用详解》 在计算机科学领域,Java开发工具包(Java Development Kit,简称JDK)是开发者进行Java编程的基础。OpenJDK作为开源版本的JDK,是Oracle JDK的替代品,提供了Java运行...

Global site tag (gtag.js) - Google Analytics