linuxed
March 21st, 2009, 08:34 AM
As many of you have probably discovered the jre available from the Ubuntu repository does not contain a 64-bit java plugin for 64-bit browsers. This means that you have to manually download, extract, and install the 64-bit plugin yourself if you want to be able to view java applets in 64-bit versions of Firefox. While this is not necessarily a cumbersome task it is certainly an inconvenience so I eventually ended up creating a deb package to automate this task. Unfortunately due to Sun's software license I can't redistribute the jre so making the deb package available for download isn't possible. However I have posted the instructions below on how to create your own deb packge which makes for an incredibly easy installation of the 64-bit java plugin.
Important: Make sure to install the sun-java6-bin package prior to installing the new jre package. Since Sun requires users to accept their license agreement prior to installing the jre it may prevent the jre64 package installation from completing successfully if you haven't already accepted their agreement.
Install sun's jre.
sudo apt-get install sun-java6-bin
Download the latest 64-bit jre from Sun. (http://www.java.net/download/jdk6/6u14/promoted/b03/binaries/jre-6u14-ea-bin-b03-linux-amd64-10_mar_2009.bin) At the moment it's version 1.6.0.14. Make sure to save the file to your desktop.
Open a terminal window and change to your desktop directory.
cd /home/yourUserName/Desktop
Type the following:
mkdir -p jre64/DEBIAN
mkdir -p jre64/usr/lib/jvm
mkdir -p jre64/usr/lib/firefox-addons/plugins
Now we're going to create the control file with gedit.
gedit jre64/DEBIAN/control
Copy ALL of the following and paste into gedit. Add your name and email address to the Maintainer line. Do not delete the < > characters.
Package: jre64
Version: 1.6.0_14
Architecture: amd64
Maintainer: YourName <yourname@yourname.com>
Installed-Size: 87869
Depends: dpkg, sun-java6-jre, sun-java6-bin, firefox (>= 3.0)
Conflicts: icedtea-gcjwebplugin, icedtea6-plugin
Section: net
Priority: extra
Homepage: http://www.ubuntuforums.org
Description: Sun java runtime with 64-bit browser plugin
This package will provide the latest jre from Sun including
a 64-bit java plugin designed to work in 64-bit browsers.
This package will automatically install the plugin for Firefox.
Click save and close gedit.
We're going to create a post install file to set the jre we're installing as the default. Type the following:
gedit jre64/DEBIAN/postinst
Copy ALL of the following and paste into gedit.
#!/bin/sh
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jre1.6.0_14/bin/java" 1
sudo update-alternatives --set java /usr/lib/jvm/jre1.6.0_14/bin/java
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jre1.6.0_14/bin/javaws" 1
sudo update-alternatives --set javaws /usr/lib/jvm/jre1.6.0_14/bin/javaws
Click save and close gedit.
Now we need to create a post remove file to restore the default jre in the event that this package is ever removed. Type the following:
gedit jre64/DEBIAN/postrm
Copy ALL of the following and paste into gedit.
#!/bin/sh
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java-6-sun/jre/bin/java" 1
sudo update-alternatives --set java /usr/lib/jvm/java-6-sun/jre/bin/java
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/java-6-sun/jre/bin/javaws" 1
sudo update-alternatives --set javaws /usr/lib/jvm/java-6-sun/jre/bin/javaws
Click save and close gedit.
Now we need to set the files we just created as executable. Type the following:
chmod +x jre64/DEBIAN/post*
Now we're going to extract the jre we downloaded earlier. Type the following:
chmod +x jre*.bin
./jre*.bin
Press enter repeatedly to navigate to the end of Sun's license. Then type "yes" to accept the license. The jre will then be extracted to a folder on your desktop. Type the following:
mv jre1.6.0_14 jre64/usr/lib/jvm
Now we need to create a symlink to the 64-bit java plugin and save it to the Firefox plugins folder. Type the following:
ln -s /usr/lib/jvm/jre1.6.0_14/lib/amd64/libnpjp2.so jre64/usr/lib/firefox-addons/plugins/libnpjp2.so
Now let's build the package.
dpkg-deb --build jre64
And finally click on the newly created package on your desktop to install it. I prefer to install packages using a gui since it allows you to easily view the details and file contents of the package, but you can also install it with "dpkg -i packageName".
You may want to test the new version of java after installing this package.
java -version
Should display something similar to the following.
java version "1.6.0_14-ea"
Java(TM) SE Runtime Environment (build 1.6.0_14-ea-b03)
Java HotSpot(TM) 64-Bit Server VM (build 14.0-b12, mixed mode)
Type the following to test the java web start version.
javaws
Should display the following.
Java(TM) Web Start 1.6.0_14-ea
Usage: javaws [run-options] <jnlp-file>
javaws [control-options]
You can test the java plugin in Firefox by typing the following in the address bar.
about:plugins
You should see the java plugin listed if the installation was successful. Java.com also offers a simple java applet test. Just click the 'Do I have java?' link.
IMPORTANT NOTE: There are a number of instances in the guide above where I've used the version "1.6.0_14" in a directory path. If you end up downloading a newer version of the jre from Sun make sure to replace those instances with the newer version. For example, replace all occurences of "1.6.0_14" with "1.6.0_15" or whatever the new version is.
UNINSTALL
To uninstall the package simply type the following:
sudo apt-get remove jre64
Important: Make sure to install the sun-java6-bin package prior to installing the new jre package. Since Sun requires users to accept their license agreement prior to installing the jre it may prevent the jre64 package installation from completing successfully if you haven't already accepted their agreement.
Install sun's jre.
sudo apt-get install sun-java6-bin
Download the latest 64-bit jre from Sun. (http://www.java.net/download/jdk6/6u14/promoted/b03/binaries/jre-6u14-ea-bin-b03-linux-amd64-10_mar_2009.bin) At the moment it's version 1.6.0.14. Make sure to save the file to your desktop.
Open a terminal window and change to your desktop directory.
cd /home/yourUserName/Desktop
Type the following:
mkdir -p jre64/DEBIAN
mkdir -p jre64/usr/lib/jvm
mkdir -p jre64/usr/lib/firefox-addons/plugins
Now we're going to create the control file with gedit.
gedit jre64/DEBIAN/control
Copy ALL of the following and paste into gedit. Add your name and email address to the Maintainer line. Do not delete the < > characters.
Package: jre64
Version: 1.6.0_14
Architecture: amd64
Maintainer: YourName <yourname@yourname.com>
Installed-Size: 87869
Depends: dpkg, sun-java6-jre, sun-java6-bin, firefox (>= 3.0)
Conflicts: icedtea-gcjwebplugin, icedtea6-plugin
Section: net
Priority: extra
Homepage: http://www.ubuntuforums.org
Description: Sun java runtime with 64-bit browser plugin
This package will provide the latest jre from Sun including
a 64-bit java plugin designed to work in 64-bit browsers.
This package will automatically install the plugin for Firefox.
Click save and close gedit.
We're going to create a post install file to set the jre we're installing as the default. Type the following:
gedit jre64/DEBIAN/postinst
Copy ALL of the following and paste into gedit.
#!/bin/sh
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jre1.6.0_14/bin/java" 1
sudo update-alternatives --set java /usr/lib/jvm/jre1.6.0_14/bin/java
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jre1.6.0_14/bin/javaws" 1
sudo update-alternatives --set javaws /usr/lib/jvm/jre1.6.0_14/bin/javaws
Click save and close gedit.
Now we need to create a post remove file to restore the default jre in the event that this package is ever removed. Type the following:
gedit jre64/DEBIAN/postrm
Copy ALL of the following and paste into gedit.
#!/bin/sh
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/java-6-sun/jre/bin/java" 1
sudo update-alternatives --set java /usr/lib/jvm/java-6-sun/jre/bin/java
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/java-6-sun/jre/bin/javaws" 1
sudo update-alternatives --set javaws /usr/lib/jvm/java-6-sun/jre/bin/javaws
Click save and close gedit.
Now we need to set the files we just created as executable. Type the following:
chmod +x jre64/DEBIAN/post*
Now we're going to extract the jre we downloaded earlier. Type the following:
chmod +x jre*.bin
./jre*.bin
Press enter repeatedly to navigate to the end of Sun's license. Then type "yes" to accept the license. The jre will then be extracted to a folder on your desktop. Type the following:
mv jre1.6.0_14 jre64/usr/lib/jvm
Now we need to create a symlink to the 64-bit java plugin and save it to the Firefox plugins folder. Type the following:
ln -s /usr/lib/jvm/jre1.6.0_14/lib/amd64/libnpjp2.so jre64/usr/lib/firefox-addons/plugins/libnpjp2.so
Now let's build the package.
dpkg-deb --build jre64
And finally click on the newly created package on your desktop to install it. I prefer to install packages using a gui since it allows you to easily view the details and file contents of the package, but you can also install it with "dpkg -i packageName".
You may want to test the new version of java after installing this package.
java -version
Should display something similar to the following.
java version "1.6.0_14-ea"
Java(TM) SE Runtime Environment (build 1.6.0_14-ea-b03)
Java HotSpot(TM) 64-Bit Server VM (build 14.0-b12, mixed mode)
Type the following to test the java web start version.
javaws
Should display the following.
Java(TM) Web Start 1.6.0_14-ea
Usage: javaws [run-options] <jnlp-file>
javaws [control-options]
You can test the java plugin in Firefox by typing the following in the address bar.
about:plugins
You should see the java plugin listed if the installation was successful. Java.com also offers a simple java applet test. Just click the 'Do I have java?' link.
IMPORTANT NOTE: There are a number of instances in the guide above where I've used the version "1.6.0_14" in a directory path. If you end up downloading a newer version of the jre from Sun make sure to replace those instances with the newer version. For example, replace all occurences of "1.6.0_14" with "1.6.0_15" or whatever the new version is.
UNINSTALL
To uninstall the package simply type the following:
sudo apt-get remove jre64