How to enable Java in Chrome and Firefox on Ubuntu

To enable Oracle's Java plugin in your Linux browsers, just copy these lines into a script, and run it!

JAVA_HOME=/usr/lib/jvm/jdk1.7.0
MOZILLA_HOME=~/.mozilla
mkdir $MOZILLA_HOME/plugins
ln -s $JAVA_HOME/jre/lib/i386/libnpjp2.so $MOZILLA_HOME/plugins

Note: You may need to change the value of JAVA_HOME so that it correctly points to your installation of the JDK. 64-bit users will need to change the final line to:
ln -s $JAVA_HOME/jre/lib/amd64/libnpjp2.so $MOZILLA_HOME/plugins

If you’re a newbie, here’s how to run the script:

  1. Using your favorite editor, paste the contents of the script into a new file.
  2. Find out where Oracle Java is installed. This location has the directories "bin", "lib", and "jre", among others. Replace the value of JAVA_HOME with the path to this folder, and save the file. This step applies if you're using the JDK. If you're only using the JRE, let JAVA_HOME point to the jre installation directory (which contains the folders "bin", "lib" and "plugin"), and modify the last line in the script to remove "jre" from the path.
  3. Make the script executable, by typing in chmod +x <filename>
  4. Run the script using the command ./<filename>
  5. Restart your browser, and confirm your installation as shown in the next section

The above script will enable Java support in both Chrome/Chromium and Firefox, since they both use the ~/.mozilla/plugins directory to scan for available plugins.

Confirming Installation

After you've restarted your browser, if you see a message below detailing your installed Java version and operating system, you'll know it's working successfully.

You can also look up the address “about:plugins” in Chrome or Firefox to get the list of plugins installed in your browser.

Alternatively, look up Oracle's How do I test whether Java is working on my computer? to confirm the version of Java your browser is using.

Troubleshooting

If you’re facing problems with your Java plugin not working correctly on certain sites, you might want to try updating Java to the latest version. Also, you could try switching to Oracle’s version (in case you’re running the OpenJRE or IBM’s JRE), since that’s what’s best supported on the web.



Comments

Wouldn't it be better to do:

apt-get install icedtea-plugin

?

It uses the default-java that is already part of Ubuntu 11.04+ without adding oracles binary version.

By Scott Carr

Looking at the description of the icedtea-plugin, this does seem to be a quick way of getting the Java plugin installed.

However, if you require a different binary version from Oracle or IBM due to compatibility issues (which is often the case), the above steps still apply.

By Abdullah Chougle

IcedTea do not work with some aplications like ADVFN.. IMO its better use Oracle Java.. Works everything.

By Fernando

Thanks. I tried everything as mentioned in this article, without succes. Followed yr advice and worked right away

By ed

1. What I don't understand is how Chromium and Chrome use the symbolic link in the ~/.mozilla/plugins folder; could someone please point me to relevant documentation with these details?
2. Why isn't Chrome listed on the list of supported browsers?
http://docs.oracle.com/javase/6/docs/technotes/guides/jweb/applet/browse...

By Phiri

Awesome help really, my plugin was not working so I uninstalled it, later found that I could not install it from synaptic.

I followed your method and it now works like a charm.

Thankz

By Preetam

The script works only for 32 bit machines and users with Java JDK 1.7.0 in a specific location. Users with different Java version and/or path need to change the first line so that they set JAVA_HOME to match the path of their Java installation. 64bit users will need to change the final line to:

ln -s $JAVA_HOME/jre/lib/amd64/libnpjp2.so $MOZILLA_HOME/plugins

Users with only a JRE (and no JDK) will also need to make a change.

By DB Whitaker

DB Whitaker,

Thank you for your useful additions. I've merged them into the main article.

By Abdullah Chougle

java version "1.7.0_07"
OpenJDK Runtime Environment (IcedTea7 2.3.2) (ArchLinux build 7.u7_2.3.2-1-x86_64)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)

i can't found the file libnpjp2.so in the path $JAVA_HOME/jre/lib/amd64/.
why?

By Junbo Liu

Hey Junbo,

A quick Google search seems to suggest that some OpenJDK builds do not ship with libnpjp2.so. Since you're using OpenJDK, sudo apt-get install icedtea-7-plugin should do the trick for you, as Scott Carr has mentioned in a comment above. Let us know if it still doesn't work.

By Abdullah Chougle

Thanks. The good thing about Java is that it's cross platform, "run anywhere". Oh wait it doesn't - you need _specific JVMs_ to run _some apps_. Bzzzt, fail.

Thank you very much sir ! This was very helpful !

By Julián

Add new comment