Skip to main content

Afraid of trying JPackage?

Posted by flozano on August 31, 2006 at 6:56 PM PDT

Most Linux developers and sysadmins I talk to think JPackage is great, once they are introduced to the advantages of not having tons of copies of every jakarta-commons-whatever and having each application automagically use the Java release (or even vendor release) it needs.

But mosf of them are scared of the bootstrapping procedure, except for the few lucy ones that already have a JPackage-compatible JVM as part of their (commercial) distros, or the few ones that are brave enough to try and find their applications already work with GCJ. Rebuilding a RPM package looks like mission impossible to them.

So I created the following shell script, that does everything you need to bootstrap your JPackage environment except for downloading Sun Java. Just save it on the same directory that has the Sun Java tarball and let it run. In the end, you'll have a few packages ready to copy and install on each Linux workstation or server in your network.

For the curious, this script (actually the JPackage RPM spec) generates the following packages:

  • java-1.5.0-sun-
  • java-1.5.0-sun-alsa-
  • java-1.5.0-sun-demo-
  • java-1.5.0-sun-devel-
  • java-1.5.0-sun-fonts-
  • java-1.5.0-sun-jdbc-
  • java-1.5.0-sun-plugin-
  • java-1.5.0-sun-src-

You may not be able to install the “sun-jdbc” package, but this does not means you won't be able to run JDBC applications. It just means you do not have installed unixODBC (and who does use the JDBC-ODBC bridge under Linux anyway?)

Likewise, you may not be able to install the “sun-alsa” package if you do not have the Alsa sound libraries installed. I personally don't think I need sound support to run my JavaEE application servers.

Finally, you do not need to install the “sun-fonts” package in every Linux workstation if you do use an X Font Server – you may need to install this only on the font server machine.

After installing the repackaged Sun Java, you can start downloading Java application packages from or, better yet, configure your yum repositories to point to the JPackage Project one.

Here's the script. It could be enhanced, for example not being hardwired to 1.5.0 update 7. But it does the work.

# builds a JPackage-compatible Sun JDK RPM
# by Fernando Lozano
# This script can be used, redistributed and changed in the terms
# of the Apache License 2.0 (
# provided these initial comments are not deleted nor modified.
# Of course you can add more comments if you like.



if [ "$1" = "-h" -o "$1" = "-help" ]; then
    echo "This script builds JPackage compatible binary RPMS"
    echo "from Sun JDK 1.5.0_07 binary download for 32-bits Linux/Intel"
    echo "options:"
    echo "  -h: ths message"
    echo "  -q: really quiet"
    echo "  -v: verbose (shows rpmbuild messages)"
    exit -1

if [ "$1" = "-q" ]; then

if [ "$1" = "-v" ]; then

echo "Checking prerequisites..." > $output

if [ -z "`which rpmbuild 2>/dev/null`" ]; then
    echo "rpmbuild not found. Either you need to adjust your PATH" 1>&2
    echo "or you need to install package rpm-devel as root" 1>&2
    exit 1

if [ -z "`which wget 2>/dev/null`" ]; then
    echo "wget not found. Either you need to adjust your PATH or" 1>&2
    echo "you need to install package wget as root" 1>&2
    exit 1

if [ ! -r $bin ]; then
    echo "$bin not found. " 1>&2
    echo "You need to download it from" 1>&2
    exit 1

echo "Configuring RPM build environment..." > $output

mv ~/.rpmmacros ~/.rpmmacros.sav.$$ 2>/dev/null
echo "
%_topdir        %(echo ${d}/tmp-$base/rpm)
%_tmppath       %{_topdir}/tmp

%packager       build-sun-java-jpp-rpm by Fernando Lozano
" > ~/.rpmmacros

echo "Creating build directories..." > $output

rm -rf tmp-$base
mkdir tmp-$base
cd tmp-$base
mkdir rpm
mkdir rpm/SOURCES
mkdir rpm/SPECS
mkdir rpm/SRPMS
mkdir rpm/RPMS
mkdir rpm/RPMS/i386
mkdir rpm/RPMS/i586
mkdir rpm/RPMS/noarch
mkdir rpm/tmp
mkdir rpm/BUILD

echo "Downloading SRPM from" > $output

wget -qc "Moving required files to build dirs..." > $output

cp ../jdk-1_5_0_07-linux-i586.bin rpm/SOURCES
rpm2cpio java-1.5.0-sun- | cpio -imud --quiet
mv java-1.5.0-sun-*fonts.xsl rpm/SOURCES
mv java-1.5.0-sun.spec rpm/SPECS

echo "Building JPackage compatible binary RPMS..." > $output

rpmbuild -ba rpm/SPECS/java-1.5.0-sun.spec > $rpmout 2>&1

echo "Finished." > $output

echo > $output
echo "Sun JDK Packages are in $d/rpm/RPMS/i586" > $output

echo "You may need to mannualy create the Java plug-in symlink for Mozilla / Firefox:" > $output
echo "# cd /usr/lib/firefox*/plugins" > $output
echo "# ln -s /usr/lib/jvm/java-sun/jre/plugin/i386/ns7/ . > $output
Related Topics >>