I am an architect at Kayak.com working mainly with Java. I focus on performance problems at work and occasionally on computer graphics as a hobby when I find the time. Derek has posted 5 posts at DZone. View Full User Profile

32 bit JDK on a 64 bit Ubuntu System

09.09.2008
| 83725 views |
  • submit to reddit

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.

Installation

First, download the latest 32 bit JDK (not JRE) from Sun. At the time this was jdk-6u7-linux-i586.bin for me.

Install java-package:

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.

 

From http://dmy999.com/

 

0
Your rating: None
Published at DZone with permission of its author, Derek Young.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Henk De Boer replied on Tue, 2008/09/09 - 2:33pm

>Of course they use about double the memory

I think this is *highly* exaggerated. Stop spreading FUD.

 

Derek Young replied on Tue, 2008/09/09 - 4:33pm

henk de boer - I'm curious, are you running a 64 bit Java on a 64 bit kernel on your desktop?  When I went from a 32 bit kernel to a 64 bit kernel I was surprised at the overhead too.  All pointers (and ints in some languages) are twice as big.  This adds a lot to the size of any process.  My intention wasn't to exaggerate.  I had to upgrade my desktop machine from 4GB to 8GB to keep my machine from swapping.  On our QA machines (that ran a lot of java processes, probably too many) we were forced to go back to 32 bit Java.  The machines would swap endlessly otherwise.  We have about 100 production systems at work, running about 6 java processes each.  We decided going to 64 bit java wasn't possible or necessary.

 

Paul Gier replied on Tue, 2008/12/09 - 10:14am in response to: Derek Young

I've had a similar experience with 64 bit linux.  It might not be double the memory, but the 64 bit jdk and eclipse definitely use a lot more memory than the 32 bit versions.

Vanessa Pacheco replied on Fri, 2009/01/30 - 4:38pm

I have an amd-64 bit processor with Hardy Heron 64-bit installed.

I'm trying to play around with GWT, which requires 32-bit jdk. I managed to install java-package following your first instruction.

I've now downloaded  jdk-6u11-linux-i586.bin, which seems to be the latest out there. When I tried step 2 which is 

DEB_BUILD_GNU_TYPE=i486-linux-gnu DEB_BUILD_ARCH=i386 fakeroot make-jpkg jdk-6u11-linux-i586.bin

I got the following error

Creating temporary directory: /tmp/make-jpkg.hArlp17113
Loading plugins: blackdown-j2re.sh blackdown-j2sdk.sh common.sh ibm-j2re.sh ibm-j2sdk.sh j2re.sh j2sdk-doc.sh j2sdk.sh j2se.sh sun-j2re.sh sun-j2sdk-doc.sh sun-j2sdk.sh

Detected Debian build architecture: i386
Detected Debian GNU type: i486-linux-gnu

No matching plugin was found.
Removing temporary directory: done

So as per instructions @ http://wiki.vuze.com/index.php/Java, I ran dpkg-architecture which told me my command should be 

DEB_BUILD_GNU_TYPE=x86_64-linux-gnu DEB_BUILD_ARCH=amd64 fakeroot make-jpkg jdk-6u11-linux-i586.bin

however, I still got the same error.

I found  some stuff here http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6500693. So I tried ./jdk-6u11-linux-i586.bin, which extracted and installed in my current dir, ie. where I currently was.

 However, sudo update-alternatives --config java didn't give me the option to change to the latest installed jdk 1.6.

 

Any thoughts?

 

 

 

 

 

Al Llister replied on Thu, 2009/03/12 - 7:35am in response to: Vanessa Pacheco

I had exactly this problem. I solved it only by going to the sun archives (http://java.sun.com/products/archive/) and downloading update 7, as the tutorial suggests. Other than using 1.6 update 7 rather than 1.6 update 12 (the current one) I could use the instructions provided as-is. There must be something different with updates 11 and 12 which makes it not work with the make-jpkg command.

 

I hope this solves the problem for you, too.

Rehan Iftikhar replied on Tue, 2009/06/16 - 6:33pm

Thanks for the get tutorial, works like a charm.

 @lister, thanks for the followup too.

 

Alex Wei replied on Tue, 2009/11/10 - 8:45am

I followed the instruction and it looked OK initially.

However, the Java application running with this JDK does not seem to be able to connect to the internet and it also had some errors like this:

 Caused by: java.lang.UnsatisfiedLinkError: /usr/lib/j2sdk1.6-sun/jre/lib/i386/xawt/libmawt.so: libXext.so.6: cannot open shared object file: No such file or directory
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1647)
    at java.lang.Runtime.load0(Runtime.java:770)
    at java.lang.System.load(System.java:1005)

I'm new to linux. So I don't really know what to do with this error. I wonder if anyone has the same problem...

Jesse Glick replied on Wed, 2011/11/02 - 3:32pm

Try: sudo apt-get install ia32-libs

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.