måndag 4 maj 2015

Installing the JRE java plugin manually in Firefox on Linux

This one was actually surprisingly easy, but I kept failing due to mistakenly using a 32 bit plugin. The first thing you want to do is check your useragent, and if you get:

Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:40.0) Gecko/20100101 Firefox/40.0

...you need the 64 bit plugin. Go to the manual Java download page and select the tar.gz marked x64. You will get a file with a similar looking name to jre-8u45-linux-x64.tar.gz depending on what version is current when you're reading this. After unpacking it, you will get a directory that we want to move somewhere else than the Download folder, so do this:

sudo mv jre1.8.0_45/ /usr/java/

You can probably place it anywhere you want, but this is as good as anything. Now, here's the part that makes Firefox actually recognize the plugin: you need a symlink to the plugin from the user plugin directory, which is under ~/.mozilla/plugins

So you would do something like this:

ln -s /usr/share/jre1.8.0_45/lib/i386/libnpjp2.so ~/.mozilla/plugins/

No relative paths! Be specific.

If you run:

ls -l ~/.mozilla/plugins/ | grep java

You should get this, confirming your successful symlink:

libnpjp2.so -> /usr/java/jre1.8.0_45/lib/amd64/libnpjp2.so

Restart Firefox and you're done. This was tried on Firefox 40a1 Nightly, so I'm pretty sure it works regardless of version.

If you're having issues, verify that:
  • You're using the 64 bit plugin for your 64 bit browser. If not, it will simply not detect it, no error is thrown. Try the 32 bit one if 64 doesn't work, and vice versa, but the user agent should have told you this already.
  • You're using absolute paths in your symlink, no "ln -s libnpjp2.so" shenanigans.