您的位置:首页 > 编程语言 > Java开发

How to compile OpenJDK on Ubuntu

2012-03-01 19:48 615 查看

How to compile OpenJDK on Ubuntu

http://www.vogella.de/articles/OpenJDK/article.html

Lars Vogel

Version 0.3

Copyright © 2009 - 2010 Lars Vogel

30.11.2008

Revision History
Revision 0.130.08.2009Lars Vogel
Created
Revision 0.2 - 0.312.11.2009 - 25.07.2010Lars 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.

Table of Contents

1. OpenJDK Overview2. Install Mercurial and Extensions3. Clone the OpenJDK repositories4. Compile OpenJDK5. Thank you6. Questions and Discussion7. Links and Literature
7.1. Source Code7.2. General

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:
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: