Installing Sun Java on Ubuntu

| 7 Comments | Bookmark and Share

I installed Azureus on my Ubuntu machine recently and found it to absolutely peg the CPU when downloading more than a few torrents at once. I know that Bittorrent is a pretty CPU intensive protocol, but I had been running similar numbers of torrents on the same machine using bittornado with much less ado. By default, Ubuntu installs the GCJ Java virtual machine, which is a perfectly serviceable JVM, but I suspected it wasn't as good as Sun's own. I'll shall not decree that Sun's JVM is better than GCJ, as I didn't actually run any tests, but Azureus runs faster now that I'm using the Sun machine. Onward.

Overall this is a pretty simple install. First, because of how Sun's JVM is licensed, you need to manually download it from the Sun site. If you plan on compiling Java code, get the Java Development Kit (JDK); if you don't write software, you can just get the Java Runtime Environment (JRE). Either way, make sure you get the vanilla package, not the RPM (RedHat package).

Once you have that, you need to install java-package using apt-get. You will first need to change two lines in your /etc/apt/sources.list file, adding universe and multiverse as is shown below:

deb http://us.archive.ubuntu.com/ubuntu/ dapper main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ dapper main restricted universe multiverse

Open a terminal and type this in, answering "yes" to any questions the program asks:

sudo apt-get install java-package

Now, you just need to make a .deb out of Sun's Java package that you grabbed. In the same terminal, change to the directory where said package resides and run the following, once again choosing happy answers like 'y' and 'yes' when you are presented with quesions:

chmod +x *.bin; fakeroot make-jpkg *.bin; sudo dpkg -i sun-j2sdk*.deb

Easy as that. To make this the default JVM simply run the following command:

sudo update-java-alternatives --config java

7 Comments

The last step I changed to sudo update-alternatives --config java (to configure the installed JVM as default) All the rest helped me out a lot Thanks

That's a better way to do it, Pommes. I've updated the how-to.

Make sure that you have multiverse (NOT just universe) in your /etc/apt/sources.list or you won't be able to get fakeroot or java-package:

Uncomment the following two lines to add software from the 'universe'

repository.

N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu

team, and may not be under a free licence. Please satisfy yourself as to

your rights to use the software. Also, please note that software in

universe WILL NOT receive any review or updates from the Ubuntu security

team.

deb http://.archive.ubuntu.com/ubuntu/ edgy universe multiverse

deb-src http://.archive.ubuntu.com/ubuntu/ edgy universe multiverse

This doesn't seem to work for java 6 ... Any idea how to do that ?

Under Feisty these days, you can simply install sun-java6-jre or sun-java6-jdk.

But this is about Dapper ...

The sun-java6 packages are in the Dapper backports repository: http://packages.ubuntu.com/dapper-backports/devel/sun-java6-jdk

Other than that, you're on your own.

About this Entry

This page contains a single entry by Drew Stephens published on May 21, 2006 5:12 PM.

Obfuscated code was the previous entry in this blog.

Mumbai, formerly known as Bombay is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 5.1