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
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-126.96.36.199-1jpp.i586.rpm -rw-r--r-- 1 root root 35903 Aug 11 22:48 java-1.6.0-sun-alsa-188.8.131.52-1jpp.i586.rpm -rw-r--r-- 1 root root 10473773 Aug 11 22:48 java-1.6.0-sun-demo-184.108.40.206-1jpp.i586.rpm -rw-r--r-- 1 root root 21709383 Aug 11 22:48 java-1.6.0-sun-devel-220.127.116.11-1jpp.i586.rpm -rw-r--r-- 1 root root 1259794 Aug 11 22:48 java-1.6.0-sun-fonts-18.104.22.168-1jpp.i586.rpm -rw-r--r-- 1 root root 26057 Aug 11 22:48 java-1.6.0-sun-jdbc-22.214.171.124-1jpp.i586.rpm -rw-r--r-- 1 root root 807126 Aug 11 22:48 java-1.6.0-sun-plugin-126.96.36.199-1jpp.i586.rpm -rw-r--r-- 1 root root 17692845 Aug 11 22:48 java-1.6.0-sun-src-188.8.131.52-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 184.108.40.206-1jpp java-1.6.0-sun-alsa-220.127.116.11-1jpp.i586.rpm 79 k java-1.6.0-sun-demo i586 18.104.22.168-1jpp java-1.6.0-sun-demo-22.214.171.124-1jpp.i586.rpm 15 M java-1.6.0-sun-devel i586 126.96.36.199-1jpp java-1.6.0-sun-devel-188.8.131.52-1jpp.i586.rpm 36 M java-1.6.0-sun-fonts i586 184.108.40.206-1jpp java-1.6.0-sun-fonts-220.127.116.11-1jpp.i586.rpm 2.0 M java-1.6.0-sun-jdbc i586 18.104.22.168-1jpp java-1.6.0-sun-jdbc-22.214.171.124-1jpp.i586.rpm 69 k java-1.6.0-sun-plugin i586 126.96.36.199-1jpp java-1.6.0-sun-plugin-188.8.131.52-1jpp.i586.rpm 1.6 M java-1.6.0-sun-src i586 184.108.40.206-1jpp java-1.6.0-sun-src-220.127.116.11-1jpp.i586.rpm 18 M Installing for dependencies: java-1.6.0-sun i586 18.104.22.168-1jpp java-1.6.0-sun-22.214.171.124-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’.
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
+ 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
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?
Hmmm, looks like I downloaded the wrong file 🙁
OK, got this:
Error: Missing Dependency: libodbcinst.so()(64bit) is needed by package java-1.6.0-sun-jdbc
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?
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.