Wednesday, March 4, 2009

OpenJDK and Sun Java (Ubuntu 8.10 64-bit)

Intro
By default Ubuntu 8.10 (64-bit) installs OpenJDK for JRE, plugins, and Web Start. Since there are some issues with OpenJDK (especially noticeable with graphics, Swing, and fonts) the suggestion is to replace it with Sun's version that is not open source. Adding Sun Java from Partner repositories did no do a job for me as plugin and web start were not available. Addiong the package ia32-sun-java6-jre solved issue with Web Start (with 32-bit web start), but applets still did not work.

Fix
  • I completely removed OpenJDK and Sun Java installed from repostiories.
  • Then I downloaded the latest (in my case JDK, you can go with JRE) from Sun's website. I selected Linux x64 architecture.
  • In terminal I ran:
    sudo bash jdk-6u12-linux-x64.bin
  • Then I moved the newly created folder to /usr/lib/jvm
  • Since trying to run java command would not be found. I ran the following:
    sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.6.0_12/bin/java 1
    sudo update-alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/jdk1.6.0_12/bin/javaws 1

  • There was no need to configure alternatives for java since there was no other Java installed. If needed, this can be done with:
    sudo update-alternatives --config java
  • To enable plugin in Firefox I needed to do the following:
    sudo ln -s /usr/lib/jvm/jdk1.6.0_12/jre/lib/amd64/libnpjp2.so /usr/lib/mozilla/plugins/
  • Restart Firefox. It should be finding 64-bit Java plugin on your Ubuntu 8.10
  • Only other thing I needed was to tell Firefox to run /usr/bin/javaws when it downloads Java Web Start programs. When prompted to download, click on "Open with" and navigate to /usr/bin/javaws. That should do it.
Comments
If I am following what I just did everything should be 64-bit version Java now: JRE, JDK, Java Web Start, and Java web browser (Firefox) plugin. Any additional suggestions or feedback are welcome.

4 comments:

Ole Irgens said...

Hi,

this was most useful. Thanks for the effort!

rgds

Ole Irgens

FLO said...

Nice! This works for 8.04 as well! Thanks!

apchar said...

I just tried this on Ubuntu 8.04 (with all the latest updates) on a dell inspiron 1721 with an AMD Turion 64 chip in it. Everything installed without a hitch and I can compile java applications just fine but firefox would not even recognize the java plugin when it was in /usr/lib/mozilla/plugins. So I instead copied libnpjp2.so to my own ~/.mozilla/plugins directory. It sees the plugin now but when I try www.javatesters.org firefox crashes. Ack.

Pieter Beyens said...

Try to use a softlink instead of a copy. That worked for me.