32 bit JDK on a 64 bit Ubuntu System
Join the DZone community and get the full member experience.Join For Free
If you have more than 3GB on your machine and you’re running Ubuntu you’ve probably had to figure out how to access that additional memory – the default Ubuntu desktop kernel will only allow access to the first 3GB. You can install the server kernel, but that’s been tuned for a server with different latency settings, etc. You can recompile the desktop kernel with HIGHMEM64 set, but then you’re stuck building the video drivers yourself.
My latest strategy has been to use the 64 bit kernel. 64 bit support is not bad now and most apps run normally. Of course they use about double the memory. If you’re running a lot of Java processes this 64 bit tax is very noticeable. For my needs, 32 bit Java is fine, even with a 64 bit kernel. Ubuntu/Debian ship a 32 bit JRE (ia32-sun-java6-bin). This package provides only the runtime environment (no javac) and the client VM so it has limited usefulness for a developer.
To install the 32 bit JDK from Sun on a 64 bit system you can use java-package. I’ve been running Eclipse and all my development applications and finally have some free memory again.
First, download the latest 32 bit JDK (not JRE) from Sun. At the time this was jdk-6u7-linux-i586.bin for me.
sudo apt-get install java-package
Now use java-package to build a .deb package from the binary you downloaded. You have to trick it into building the 32 bit package:
DEB_BUILD_GNU_TYPE=i486-linux-gnu DEB_BUILD_ARCH=i386 fakeroot make-jpkg jdk-6u7-linux-i586.bin
This should generate a .deb package. For some reason the package name has the _amd64 suffix. Install the package:
sudo dpkg -i sun-j2sdk1.6_1.6.0+update7_amd64.deb
Use update-alternatives to select the new JDK. It was installed at
/usr/lib/j2sdk1.6-sun for me.
sudo update-alternatives --config java
If you run java -version you should see the correct version:
java version "1.6.0_07"
Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
Java HotSpot(TM) Server VM (build 10.0-b23, mixed mode)
32 bit Eclipse
I had to reinstall the 32 bit version of Eclipse (since SWT contains native code). I also had to delete my
~/.eclipse directory or Eclipse wouldn’t start (this requires reinstalling new versions of any plugins). Finally, add the new JRE in Java->Installed JREs using the install location (
/usr/lib/j2sdk1.6-sun) and select it as the default.
Opinions expressed by DZone contributors are their own.