Due to the Java packaging discussion, and the fact that I have to go through this procedure for a machine right this very moment, here is the "best practice" for installing a proprietary Java JDK on a RedHat- ish (includes CentOS, probably Fedora) Linux distribution.

I consider this method to be much more maintainable than just installing the RPM from Sun. It splits the big fat RPM into smaller optional packages, and does nice things like integrate with the 'alternatives' system of the OS. It's also a procedure you can do once to create your own private yum repository of RPMs, which can then be distributed to dozens of servers.

Obviously when the community gets done packaging the GPL'd version of Java this will become obsolete, but meanwhile lots of apps still expect the real Sun JDK, and possibly require older versions that will never be OSS distributable. Therefore this is a good method to keep in your back pocket, and props to the jpackage.org crew for making it possible.

Ingredients:

1) Linux JDK in standard format (a.k.a "Linux self-extracting file," *not* the RPM version) from java.sun.com
2) Magic "nosrc" RPM from jpackage.org

The ingredients above are available for Java 1.4, 1.5 and 1.6 from Sun, as well as some JDK revisions from IBM. In this example, I'll be building Sun 1.6. Therefore for I have on my disk "jdk-6u3-linux- i586.bin" from Sun, and "java-1.6.0-sun-1.6.0.3-1jpp.nosrc.rpm" from http://www.jpackage.org/browser/rpm.php?jppversion=1.7&id=7539

First install the .nosrc.rpm from jpackage.org. Even though the name differs, this is the same as installing a .src.rpm - there is no actual installation of software, nor any recrords added to the RPM database. Instead, the contents of .nosrc.rpm are unpacked into the / usr/src/redhat directory, which is meant for RPM building[1].

In this case, the .nosrc.rpm contains only a .spec file (placed in the SPECS directory) and two .xsl files (placed in the SOURCES directory). It's up to you to add the JDK "source" package yourself, so place the .bin file downloaded from Sun into SOURCES.

With all that in place, you're ready to go. The .spec file contains all the magic needed to build your RedHat-friendly Java RPMs:

rpmbuild -ba /usr/src/redhat/SPECS/java-1.6.0-sun.spec

After some churning, rpmbuild should report success, and in /usr/src/ redhat/RPMS/i586, you should find a nice selection of java-* RPMs. Install the ones appropriate to your needs and enjoy! If you've installed more than one version of Java via this method, or if you have gcj installed, you may have to use the 'update-alternatives' utility to adjust which JDK/JRE is selected by default.


[1] The jpackage.org project (and many other system administrators) recommend that instead of building RPMs as root in the /usr/src/redhat tree, it's best to make a private RPM build tree in a normal user's directory and build the packages as that user. Instructions on how to do this can be found under "Initial Setup" here: http://www.jpackage.org/develdocs.php

--
Joshua Penix                                http://www.binarytribe.com
Binary Tribe           Linux Integration Services & Network Consulting

--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg

Reply via email to