How to compile OpenJDK on Ubuntu

本文详细介绍了如何在Ubuntu系统上下载并编译OpenJDK源代码的步骤,包括安装Mercurial及扩展、克隆仓库、配置环境变量进行编译,最终验证编译结果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

How to compile OpenJDK on Ubuntu
http://www.vogella.de/articles/OpenJDK/article.html

Lars Vogel

Version 0.3

30.11.2008

Revision History
Revision 0.1 30.08.2009 Lars Vogel
Created
Revision 0.2 - 0.3 12.11.2009 - 25.07.2010 Lars Vogel
bug fixes and enhancements

OpenJDK

This article describes how to download the source code of OpenJDK and how to compile it. The platform which is used in Ubuntu.


1. OpenJDK Overview

OpenJDK is the open source implementation of Java. OpenJDK is under version control by a distributed version control system called Mercurial . This guide will describe how to install Mercurial, download the source code of OpenJDK and how to compile OpenJDK.

2. Install Mercurial and Extensions

You first need to make sure Mercurial is installed on your system.

			
sudo apt-get install mercurial

		

In addition to standard Mercurial you also need the Forest Extension. These are currently not packages for Ubuntu, see Bug report

You can get the forest extension via the following command. This will create the directory hgforest with the file "forest.py".

			
# close the forest extensions
# if the url below does not work you find alternative url via 
# http://bitbucket.org/repo/all?name=hgforest
hg clone https://vogella@bitbucket.org/vogella/hgforest-crew

		

Edit the file "~/.hgrc" (i.e. the mercurial configuration file) to include the lines.

			
[extensions]
forest=/home/vogella/hgforest/forest.py
		

After this change you should be able to use commands such as 'fclone' and 'fpull' is you type in "hg" in the command line.

Install the build dependencies via the following commands:

			
sudo aptitude build-dep openjdk-6

sudo aptitude install openjdk-6-jdk 

		

3. Clone the OpenJDK repositories

Clone the OpenJDK7 respositories via the following command.

			
hg fclone http://hg.openjdk.java.net/jdk7/jdk7
		

Alternatively you can clone OpenJDK6 via the following command.

			
hg fclone http://hg.openjdk.java.net/jdk6/jdk6
		

4. Compile OpenJDK

Switch into you OpenJDK directory and compile it via:

			
#set a few environment variables for the build:
export LANG=C ALT_BOOTDIR=/usr/lib/jvm/java-6-openjdk 
make ALLOW_DOWNLOADS=true


		

After a long time the compilation should be successful. The default output directory is build/platform, where platform your operating system. The build/platform/j2sdk-image/bin should contain executables for the OpenJDK tools. The "demo" dirctory contains several demos which you can use to validate your build. Try "./java -version" in your "/build/platform/bin" and validate that you see the version of OpenJDK which you compiled against.

5. Thank you

Please help me to support this article:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值