Installing Sun Java on Ubuntu
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


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
[Reply]
Comment by Pommes — November 10, 2006 @ 4:00 pm
That’s a better way to do it, Pommes. I’ve updated the how-to.
[Reply]
Comment by Dinomite — November 10, 2006 @ 4:09 pm
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
[Reply]
Comment by gravyface — December 8, 2006 @ 7:04 pm
This doesn’t seem to work for java 6 … Any idea how to do that ?
[Reply]
Comment by Christof — July 27, 2007 @ 10:03 am
Under Feisty these days, you can simply install
sun-java6-jreorsun-java6-jdk.[Reply]
Comment by Drew Stephens — July 27, 2007 @ 2:08 pm
But this is about Dapper …
[Reply]
Comment by Christof — July 28, 2007 @ 4:13 am
The
sun-java6packages are in the Dapper backports repository: http://packages.ubuntu.com/dapper-backports/devel/sun-java6-jdkOther than that, you’re on your own.
[Reply]
Comment by Drew Stephens — July 28, 2007 @ 7:39 am