When I set out to install Sun’s latest Java development kit on my newly upgraded Fedora 10 development box, I discovered the previous instructions I had used on Fedora 8 from the Fedora FAQ no longer cover installing the Sun JDK. The instructions now refer only to OpenJDK using the java-1.6.0-openjdk package. After a short search, I found a newer installation technique, but unfortunately had to tweak it because it didn’t work with JDK 6u12.

The best instructions I found for installing the Sun JDK on Fedora were from Fedora developer Paul Howarth at www.city-fan.org/tips/SunJava6OnFedora. Paul’s instructions and his modified jpackage Java 6 RPM package are fantastically helpful. He details how to custom-build Java installation RPMs by rebuilding his RPM with the Sun Microsystems Java 1.6 “bin” installer.

The only roadblock to success was that Paul built his RPM for Java 6 update 7. The RPM spec file doesn’t work if you run it with Sun’s latest (as of this writing) jdk-6u12-linux-i586.bin file. My first attempt to follow Paul’s instructions got me this:

[tom@development Download]$ rpmbuild --rebuild java-1.6.0-sun-1.6.0.7-1.1.cf.nosrc.rpm
Installing java-1.6.0-sun-1.6.0.7-1.1.cf.nosrc.rpm
warning: InstallSourcePackage at: psm.c:246: Header V3 DSA signature: NOKEY, key ID b56a8bac
warning: user paul does not exist - using root
warning: group paul does not exist - using root
warning: user paul does not exist - using root
warning: group paul does not exist - using root
warning: user paul does not exist - using root
warning: group paul does not exist - using root
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.W96jt0
+ umask 022
+ cd /home/tom/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ rm -rf /home/tom/rpmbuild/BUILD/jdk1.6.0_07
+ export MORE=10000
+ MORE=10000
+ sh /home/tom/rpmbuild/SOURCES/jdk-6u7-linux-i586.bin
sh: /home/tom/rpmbuild/SOURCES/jdk-6u7-linux-i586.bin: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.W96jt0 (%prep)

The warnings are harmless. But as you can see, during the “prep” stage, rpmbuild is expecting the bin file to be called jdk-6u7-linux-i586.bin instead of the bin file for update 12. I optimistically hoped I might be able to get around this snag by renaming the newer file to the older name:

[tom@development Download]$ mv ~/rpmbuild/SOURCES/jdk-6u12-linux-i586.bin ~/rpmbuild/SOURCES/jdk-6u7-linux-i586.bin

But that just got me one step farther:

[tom@development Download]$ rpmbuild --rebuild java-1.6.0-sun-1.6.0.7-1.1.cf.nosrc.rpm
Installing java-1.6.0-sun-1.6.0.7-1.1.cf.nosrc.rpm
warning: InstallSourcePackage at: psm.c:246: Header V3 DSA signature: NOKEY, key ID b56a8bac
warning: user paul does not exist - using root
warning: group paul does not exist - using root
warning: user paul does not exist - using root
warning: group paul does not exist - using root
warning: user paul does not exist - using root
warning: group paul does not exist - using root
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.1AYQKX
+ umask 022
+ cd /home/tom/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ rm -rf /home/tom/rpmbuild/BUILD/jdk1.6.0_07
+ export MORE=10000
+ MORE=10000
+ sh /home/tom/rpmbuild/SOURCES/jdk-6u7-linux-i586.bin
+ cd /home/tom/rpmbuild/BUILD
+ cd jdk1.6.0_07
/var/tmp/rpm-tmp.1AYQKX: line 33: cd: jdk1.6.0_07: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.1AYQKX (%prep)

The rpmbuild was able to find and run Sun’s (renamed) shell script, but then failed when it tried to switch to the non-existent jdk1.6.0_07 directory in BUILD.

To solve the problem, I had to edit the RPM “spec” file and make two small changes to account for the updated version. Then I continued with Paul’s instructions, except using the modified spec file in place of directly using his RPM file. I got the idea of editing the spec file from a blog posting by Nick Lothian.

Here are my modification’s to Paul’s instructions,

  • Follow Paul’s instructions up to and including running the rpmbuild command under the section “Build Java RPM Packages.”</p>
  • Begin Detour: After you get the error (shown above) that says “jdk-6u7-linux-i586.bin: No such file or directory,” you won’t have the RPM files but you will have an RPM spec file stored in ~/rpmbuild/SPECS, called java-1.6.0-sun.spec.</p>
  • Edit this ~/rpmbuild/SPECS/java-1.6.0-sun.spec file by:

    Changing this line (line 37 in my spec file):</p>

    %define buildver        7
    

</pre>

to say:
   
<pre>%define buildver        12

</pre>

so the buildver is 12 instead of 7, 
and changing this line (line 45 in my spec file):
   
<pre>%define toplevel_dir    jdk%{javaver}_0%{buildver}

</pre>

to say:
   
<pre>%define toplevel_dir    jdk%{javaver}_%{buildver}

</pre>

That is, 
remove the &#8220;0&#8221; (zero) right before the %{buildver} variable. 
That second change stumped me at first because Paul apparently 
had to add a zero-padding in the directory name to get &#8220;07&#8221; 
when he was working with Update 7.
  • Run rpmbuild again by using the spec file instead of the rpm file using this command:
    [tom@development Download]$ rpmbuild -ba --rebuild ~/rpmbuild/SPECS/java-1.6.0-sun.spec
    

</pre>

This command should succeed with building new RPMs for Sun&#8217;s JDK.
  • End Detour. Continue with Paul’s instructions under “Remove Any Old Cruft.”

Now that I have the Sun JDK installed, I’m am curious whether I can find situations where OpenJDK performs differently from Sun’s JDK. Thanks to the handy “alternatives” Linux command that lets me easily switch between the different JDK versions, I’ll be able to test my Java applications within both environments. After a sudo alternatives –config java, I have:

[tom@development ~]$ java -version
java version "1.6.0_12"
Java(TM) SE Runtime Environment (build 1.6.0_12-b04)
Java HotSpot(TM) Server VM (build 11.2-b01, mixed mode)

Success.