The following applies to Java 6. I don't know what needs to change for Java 7. Is this the best way to do this? Probably not. If you know of something better, please let me know.
Get and deflate the JRE binaries
- Go to the Oracle Java for Linux page and follow the directions to download the *.bin (i.e., Linux self-extracting) file. (I opted not to use the RPM version even though Alien is available in Debian to install RPMs. The Java RPM is so full of stuff and Alien is so less than 100% reliable that I didn't want to risk messing up my system.)
- As root, make a directory /opt/java
- Copy the *.bin you downloaded above into /opt/java and issue the following commands in a terminal (as root):
# chown root:root {name-of-the-file-you-downloaded}
# chmod a+x {name-of-the-file-you-downloaded}
# ./{name-of-the-file-you-downloaded}
The first one makes sure the file is owned by root, the second one makes the file executable, and the third one executes the file -- which deflates all the Oracle Java goodness into a directory called something like jre1.6.0_xx. - Create a link called jre to the directory jre1.6.0_xx (or whatever) created above. This link will make updating the binaries much easier in the future. Use this link from now on to reference files in the jre1.6.0_xx (or whatever) directory.
- Use your favorite method to install the galternatives package from the repositories. Galternatives gives you a nice GUI interface to the "Debian alternatives" system. We will need this to override the default system alternative you may already have for the java command.
- Open Galternatives and look for an entry in the "Alternatives" column on the left called "java". If you don't have a "java" entry, skip the next step.
- When you click on the "java" entry in Galternatives, the right pane should show you a list of available alternatives that you can set your system to use as the java command. Click the "Add" button on the bottom of the window and navigate to /opt/java/jre/bin/java . After you close the file browser dialog and return to the main window, click the radio button next to the /opt/java/jre/bin/java choice to tell the system that you want to use that java to handle java commands. Skip the next step and go directly to Testing.
- Do this step only if you did NOT have a "java" entry in Galternatives. Create a soft link from /usr/bin/java to /opt/java/jre/bin/java . (Changing the /usr/bin/java link when it has been set by the Debian alternatives system may give you a whole lot of future pain, so mind the caution!)
- Open a terminal and enter the command
$ java -version
The resulting output should give you a version number that matches what you downloaded above. If it doesn't, something went wrong.
Configure browser plugin
The directions for installing the browser plugin given by Oracle may leave some browsers out in the cold. I put together a script that creates a link to the plugin in all the locations that the last debian sun-java1.6 plugin package did.
- Download the script from here.
- Look it over to make sure it's configured correctly for your system.
- In a terminal (as root):
# chmod a+x {name-of-the-file-you-downloaded}
# ./{name-of-the-file-you-downloaded} - Restart your browser and test that applets are working by going to the Oracle Java test page.
If you study the script carefully, you will see that there are commented-out bits that you can use to remove the links it created. Lemme know if you need to do this but can't figure out what to do.
Configure Webstart
In Iceweasel and Opera, configuring Java Web Start for me was as simple as going to a page that had a Java Web Start app in it (e.g., this one), clicking on it, and then directing the browser to use /opt/java/jre/bin/javaws.
I was able to get Chrome to work in a roundabout way by first downloading a *.jnlp file and then using my file manager (Thunar in Xfce) to tell it to open *.jnlp files with javaws by default. After that, in Chrome I downloaded a *.jnlp file again and then (still in in Chrome) I clicked the arrow next to the file name and selected "Always open files of this type." There may be a better way to do this.
Put the Java binaries on the PATH
There's a bunch of execuatables in /opt/java/jre/bin that will make life a lot easier if they are on the PATH. To that end,
- As root, copy the file found here to /etc/profile.d/oracle_java_mfk.sh (the actual name isn't really that important as long as it ends with .sh).
- Reboot.
$ which keytool
The result should point to the executable in /opt/java/jre/bin. If doing this spooks you (it is, after all, a system file), you can still get by without. But you will have to launch things like the Java Control Panel and other goodies from the /opt/java/jre/bin directory rather than as a command or by using one of the convenient GUI desktop entries (discussed below).
Install desktop files
There are a bunch of files in /opt/java/jre/lib/desktop that help to integrate the JRE into you system. These aren't critical, but they're probably nice to have. At the very least, they add a menu entry to start the Control Panel. I have written a script to install these files here.
Note that this script copies stuff into your system, which means 1. it will clobber resources you might already have (which you shouldn't if you completely removed the Wheezy sun-java6 packages) and 2. it makes uninstalling a tedious process of manually deleting the files that were copied over. Don't delete the directories mentioned in the scripts! There is probably stuff in those directories that your system needs. Instead, look at the files in the directories and subdirectories in /opt/java/jre/lib/desktop and delete each of those manually. (For more info on MIME stuff see http://developer.gnome.org/integration-guide/stable/mime.html.en).
Install Java fonts
Oracle Java includes a group of fonts from the Lucida family of typefaces. Yup, I've got another script for installing those, and you'll find it here. More than you ever wanted to know about fonts in Debian is here.
Updating the system
When a new version of the JRE is released, updating should really be just a matter of deleting everything in /opt/java and repeating the steps in the Get and deflate the JRE binaries section. If you want to be really thorough though, you'll also want to repeat Install desktop files and Install Java fonts sections.
The somewhat massive gorilla in the room now is, "How do you know if an update is available." Sadly, for this I have no brilliant solution. That means you should probably check the Java SE Downloads page occasionally to see if one has been released.
Update 2011-11-26: Added Install desktop files section. Added the Install Java fonts section.
Update 2011-11-27: Changed path to javaws executable and updates info on getting Webstart to work with Chrome. Added comments about (not) getting notified of updates in Updating the system. Added how to configure plugins in Chrome to Configure browser plugin.
1 comment:
Thank you very much. Tested and worked fine for me on Debian Wheezy Stable amd64. Just what I needed.
Nicholas A. Shake
Post a Comment