Sun Java for CentOS 5 5

Posted by Bill McGonigle Tue, 12 Aug 2008 03:03:00 GMT

Unfortunately the GNU java in CentOS 5 is too old to run modern Java code. So, you need to install the Sun version in many cases, and the jpackage method is typically the best way to do that. Two problems, though:

  • They don’t have an RPM that represents the current Sun version
  • Their version doesn’t work well on CentOS due to CentOS RPM bugs

If you don’t have them already installed, you need the RPM development tools. Something like:

yum -y install rpm-build rpmdevtools

should be sufficient. (note: I’m assuming you’re root. Most of this can also be done with a local RPM build tree and sudo, but is beyond the scope of this article).

As of this writing the current security release of the Java JDK is 1.6u7, which you can get here. Pick 32-bit linux (the only type I tested) get the linux non-RPM version, and put the downloaded ‘.bin’ file in /usr/src/redhat/SOURCES.

Now, download my updated spec file and put it in /usr/src/redhat/SPEC. If you’re on a Fedora platform or CentOS fixes their version of rpm you might want this non-CentOS spec instead. This latter one builds everything just fine on CentOS but there are UnixODBC link errors due to the rpm bug.

Now, build Java with:

cd /usr/src/redhat
          rpmbuild -ba SPEC/java-1.6.0-sun-centos-5.spec
          

This will take a while. You should wind up with a bunch of RPM files in RPMS/i586/, like this:

-rw-r--r-- 1 root root 43085836 Aug 11 22:48 java-1.6.0-sun-1.6.0.7-1jpp.i586.rpm
          -rw-r--r-- 1 root root    35903 Aug 11 22:48 java-1.6.0-sun-alsa-1.6.0.7-1jpp.i586.rpm
          -rw-r--r-- 1 root root 10473773 Aug 11 22:48 java-1.6.0-sun-demo-1.6.0.7-1jpp.i586.rpm
          -rw-r--r-- 1 root root 21709383 Aug 11 22:48 java-1.6.0-sun-devel-1.6.0.7-1jpp.i586.rpm
          -rw-r--r-- 1 root root  1259794 Aug 11 22:48 java-1.6.0-sun-fonts-1.6.0.7-1jpp.i586.rpm
          -rw-r--r-- 1 root root    26057 Aug 11 22:48 java-1.6.0-sun-jdbc-1.6.0.7-1jpp.i586.rpm
          -rw-r--r-- 1 root root   807126 Aug 11 22:48 java-1.6.0-sun-plugin-1.6.0.7-1jpp.i586.rpm
          -rw-r--r-- 1 root root 17692845 Aug 11 22:48 java-1.6.0-sun-src-1.6.0.7-1jpp.i586.rpm
          

Use yum to install them like this:

cd RPMS/i586
          yum --nogpgcheck localinstall java-1.6.0-sun-*.rpm
          

It should find dependencies, something like this:

Dependencies Resolved
          
          =============================================================================
           Package                 Arch       Version          Repository        Size 
          =============================================================================
          Installing:
           java-1.6.0-sun-alsa     i586       1.6.0.7-1jpp     java-1.6.0-sun-alsa-1.6.0.7-1jpp.i586.rpm   79 k
           java-1.6.0-sun-demo     i586       1.6.0.7-1jpp     java-1.6.0-sun-demo-1.6.0.7-1jpp.i586.rpm   15 M
           java-1.6.0-sun-devel    i586       1.6.0.7-1jpp     java-1.6.0-sun-devel-1.6.0.7-1jpp.i586.rpm   36 M
           java-1.6.0-sun-fonts    i586       1.6.0.7-1jpp     java-1.6.0-sun-fonts-1.6.0.7-1jpp.i586.rpm  2.0 M
           java-1.6.0-sun-jdbc     i586       1.6.0.7-1jpp     java-1.6.0-sun-jdbc-1.6.0.7-1jpp.i586.rpm   69 k
           java-1.6.0-sun-plugin   i586       1.6.0.7-1jpp     java-1.6.0-sun-plugin-1.6.0.7-1jpp.i586.rpm  1.6 M
           java-1.6.0-sun-src      i586       1.6.0.7-1jpp     java-1.6.0-sun-src-1.6.0.7-1jpp.i586.rpm   18 M
          Installing for dependencies:
           java-1.6.0-sun          i586       1.6.0.7-1jpp     java-1.6.0-sun-1.6.0.7-1jpp.i586.rpm   68 M
           libXp                   i386       1.0.0-8.1.el5    base               23 k
           unixODBC-devel          i386       2.2.11-7.1       base              739 k
           unixODBC                i386       2.2.11-7.1       base              832 k
          

And yum should download and complete without errors.

Now, make sure that this new version of Java is set to be the default with:

/usr/sbin/alternatives --config java

and enjoy current java. Hopefully it won’t be long before Sun gets its code freed so next time you can just ‘yum -y install sun-java’.

del.icio.us:Sun Java for CentOS 5 digg:Sun Java for CentOS 5 reddit:Sun Java for CentOS 5 spurl:Sun Java for CentOS 5 wists:Sun Java for CentOS 5 simpy:Sun Java for CentOS 5 newsvine:Sun Java for CentOS 5 blinklist:Sun Java for CentOS 5 furl:Sun Java for CentOS 5 fark:Sun Java for CentOS 5 blogmarks:Sun Java for CentOS 5 Y!:Sun Java for CentOS 5 smarking:Sun Java for CentOS 5 magnolia:Sun Java for CentOS 5 segnalo:Sun Java for CentOS 5
Trackbacks

Use the following link to trackback from your own site:
http://blog.bfccomputing.com/articles/trackback/4775

Comments

Leave a response

  1. Richard Sharpe 14 days later:

    Hmmm,

    I tried the above steps, but I always get the following when trying to build (btw, I think it might be SPECS not SPEC):

    rpmbuild -ba SPECS/java-1.6.0-sun-centos-5.spec Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.51692

    • umask 022
    • cd /usr/src/redhat/BUILD
    • rm -rf /usr/src/redhat/BUILD/jdk1.6.0_07
    • export MORE=10000
    • MORE=10000
    • sh /usr/src/redhat/SOURCES/jdk-6u7-linux-x64.bin replace jdk-6u7-linux-amd64.rpm? [y]es, [n]o, [A]ll, [N]one, [r]ename: NULL (assuming [N]one) package jdk-1.6.0_07-fcs is already installed
    • cd /usr/src/redhat/BUILD
    • cd jdk1.6.0_07 /var/tmp/rpm-tmp.51692: line 28: cd: jdk1.6.0_07: No such file or directory error: Bad exit status from /var/tmp/rpm-tmp.51692 (%prep)

    RPM build errors:

    Bad exit status from /var/tmp/rpm-tmp.51692 (%prep)

    This suggests that the .bin file I have is not creating the directory jdk1.6.0_07 or something.

    Any ideas what is going wrong?

    realrichardsharpe@gmail.com

  2. Richard Sharpe 14 days later:

    Hmmm, looks like I downloaded the wrong file :-(

  3. Richard Sharpe 14 days later:

    OK, got this:

    Error: Missing Dependency: libodbcinst.so()(64bit) is needed by package java-1.6.0-sun-jdbc

  4. Richard Sharpe 14 days later:

    OK, it doesn’t matter if I build with or without the CentOS specific SPEC file. I get the same problem each time with the bogus libodbcinst.so required …

    Maybe I need to remove them?

  5. Richard Sharpe 15 days later:

    Finally got them installed with

    • rpm -Uvh –nodeps java*.rpm

    I don’t care about ODBC, I just want to run the Fedora/CentOS directory services admin tool.

Comments