This article will guide you to build OpenJDK in your 64-bit Ubuntu Linux (11.10 Oneiric Ocelot or 12.04 Precise Pangolin) without many trials and errors. It is based on the official OpenJDK build README, but the README file is out-of-date, and that’s why I wrote this guide.
Assumptions
- You run 64-bit Ubuntu.
- Your Sun/Oracle JDK 6 is installed at
$HOME/.local/opt/jdk/1.6
.- You can use your preferred installation location but you will have to adjust the scripts appear in this article.
- You installed Apache Ant and the
ant
command is in yourPATH
variable. - You keep your development stuff at
$HOME/Workspace
.- This guide keeps OpenJDK source code at
~/Workspace/openjdk
and HgForest at~/Workspace/hgforest
. However, you can keep them in different locations and adjust the scripts appear in this article.
- This guide keeps OpenJDK source code at
Install required packages
apt-get install mercurial gawk g++ libcups2-dev libasound2-dev libfreetype6-dev libx11-dev libxt-dev libxext-dev libxrender-dev libxtst-dev libfontconfig1-dev
Install HgForest
hg clone https://bitbucket.org/pmezard/hgforest-crew/overview/ "$HOME/Workspace/hgforest"
Edit your $HOME/.hgrc
to add these lines:
[extensions]
forest=~/Workspace/hgforest/forest.py
Clone the OpenJDK 7 repository
hg fclone http://hg.openjdk.java.net/jdk7u/jdk7u "$HOME/Workspace/openjdk"
Apply some patches
If you need to apply some patches, do it now, and then continue to build.
Build the OpenJDK 7
cd "$HOME/Workspace/openjdk"
unset JAVA_HOME
export LANG=C
export ALT_BOOTDIR="$HOME/.local/opt/jdk/1.6"
export ALLOW_DOWNLOADS=true
export EXTRA_LIBS=/usr/lib/x86_64-linux-gnu/libasound.so
source jdk/make/jdk_generic_profile.sh
make sanity && make && echo 'Images at: build/linux-amd64/j2sdk-image'
I usually write a build script that automatically sets the environment variables and calls make
.
Once the build process is successful, you will find your OpenJDK image at build/linux-amd64/j2sdk-image
.
I tried your steps, but every time my Linux box gets crashed.
My MBP 2011 just builds OpenJDK 7 fine. No crash.
please are you on gtalk i am doing it now, please ping me
Your Sun/Oracle JDK 6 is installed at $HOME/.local/opt/jdk/1.6.
You can use your preferred installation location but you will have to adjust the scripts appear in this article.
I am not sure where my jdk 1.6 is, I lately also have installed jdk 1.7 which i installed via the ubuntu software center utility.
will try to modify the paths but already think it could fail to work.
~ hg import ../fontfix.patch
applying ../fontfix.patch
unable to find ‘make/sun/font/Makefile’ for patching
1 out of 1 hunks FAILED — saving rejects to file make/sun/font/Makefile.rej
unable to find ‘src/share/native/sun/font/freetypeScaler.c’ for patching
7 out of 7 hunks FAILED — saving rejects to file src/share/native/sun/font/freetypeScaler.c.rej
abort: patch failed to apply
You can just download it from java.oracle.com and run the .bin installer to extract the distribution, and put it somewhere you want it to be.
Just use a patch command. It seems like you are applying the patch on a wrong directory – ‘hg import’ fails to find the files to patch.
I used the patch command, and it is the same error. Please help me :’( been two days already on this.
I guess I gave all the information I can give. (cd openjdk/jdk; patch -p1 < fontfix.patch) just works for me.
now the patch command worked ok
now trying to compile …
thanks
one more thing is that you are mixing the title jdk7 and within the instructions you still rely on jdk6, so i am confused by that, could you please clarify? thanks!
ok so we figured out how to do things properly. It was more messy than we expected, the build was successful however the results were like this:
!http://img6.imagebanana.com/img/8maciqss/Selection_309.png!