= Sun Java 5 on Fedora = ----- '''Important Note:''' [[http://java.sun.com/javase/downloads/index_jdk5.jsp|Sun Java 5 has reached its End Of Service Life]]. This means that it is no longer supported by Sun and almost certainly has serious security issues - there have been multiple security updates for Sun Java 6 since the last Sun Java 5 release. Whilst it is still possible to download, install and use Sun Java 5, it is strongly discouraged. ----- This guide is derived from my original JpackageJava article that was written around the time of Fedora Core 4. Since then, much has changed: the X Window System used on Fedora has changed to [[FedoraProject:Xorg/Modularization|Modular X]], which means that many programs and their data have moved around in the filesystem, some of Sun's Java platform has been released as free software (WikiPedia:OpenJDK) in the form of [[http://fedoraproject.org/wiki/Interviews/ThomasFitzsimmons|Iced Tea]] on Fedora, and even the package management tools have gained some useful options that make this process simpler than it once was. Sun Java 5 is now "old" software, with Sun Java 6 being the current generation. However, there is still some software out there that requires Java 5 and won't actually run with later versions. This guide is for the people that need to use such software on Fedora. I tested it to some extent on Fedora 11 but believe it should work on older releases down to Fedora 7 too. == JPackage Project == This guide is based on building RPM packages for Sun Java "[[http://jpackage.org/aboutjpp.php|the JPackage way]]". This is because: 1. RPM packages are easier to install, upgrade, and uninstall on Fedora than other packaging techniques 1. Fedora's own java-related packages are designed to be compatible with JPackage However, JPackage's Sun Java packages are still targeted at distributions that use the old filesystem layout, and this leads to problems when trying to install and use the native JPackage packages on current Fedora releases. For this reason, I have created a modified version of the JPackage `java-1.5.0-sun` package that addresses many of these issues, and this guide uses the modified package. For those that are interested, the differences between my package and the JPackage version (which are limited to the spec file) can be found [[http://trac.city-fan.org/cfo-trac/changeset?old_path=/java-1.5.0-sun/branches/jpackage/java-1.5.0-sun.spec&new_path=/java-1.5.0-sun/trunk/java-1.5.0-sun.spec|here]]. The key differences are: * Dependencies are fixed for Fedora compatibility * The complex mechanism for maintaining Java plugin symlinks for Mozilla and Firefox (which doesn't actually work in Fedora) is replaced by simply using the ''alternatives'' system to maintain a single symlink in `/usr/lib/mozilla/plugins`, which works just fine for all [[WikiPedia:Gecko_(layout_engine)|gecko]]-based browsers as far as I know * A link to the ''Java Web Start'' program is added in `/usr/bin`, again maintained using the ''alternatives'' system (Fedora 11 uses this approach in OpenJDK too) * The `/etc/mailcap` and `/etc/mime.types` files, which belong to base Fedora packages, are not edited as part of the RPM install; instead, the desktop MIME database is updated to support applications using ''Java Web Start'', which now works "out of the box" in Firefox and maybe other browsers too * The dependency on `/usr/sbin/chkfontpath` (and all uses of it) are removed; font paths are now set by dropping a symlink in the `/etc/X11/fontpath.d` directory instead (the `chkfontpath` package was removed from the distribution in Fedora 9) == Create RPM Build Environment == If you have not built RPM packages using your regular user account (not root) before, you should [[CreateRPMBuildEnvironment|create an RPM build environment]] for your account before going any further. == Download jdk-1_5_0_22-linux-i586.bin from Sun == 1. Go to http://java.sun.com/j2se/1.5.0/download.jsp 1. Click on the ''Download'' link for ''JDK 5.0 Update 22'' 1. Fill in the registration form if required and await the download link by email; note that Sun's server does not retry mail so you may have problems if your mail server uses greylisting 1. Go to the mailed download link 1. Select the ''Linux'' platform from the drop-down list, and check the box marked ''I agree to the Java Development Kit 5.0 License Agreement'' (for ''x86_64'', select ''Linux x64'' as the platform) 1. Click on the ''Continue'' button 1. Click the link `jdk-1_5_0_22-linux-i586.bin` (`jdk-1_5_0_22-linux-amd64.bin` for ''x86_64'') to download the file /!\ The ''x86_64'' version does not include Java Web Start or the browser plugin, for which you should build and use the ''i586'' version. == Copy jdk-1_5_0_22-linux-i586.bin to SOURCES == {i} You might have a different download directory for your browser. {{{ [localhost ~]$ cd download/ [localhost download]$ ls jdk-1_5_0_22-linux-i586.bin [localhost download]$ cp jdk-1_5_0_22-linux-i586.bin ~/rpmbuild/SOURCES/ [localhost download]$ }}} /!\ For installs on ''x86_64'' systems, the filename is of course `jdk-1_5_0_22-linux-amd64.bin` == Download java-1.5.0-sun-1.5.0.22-1.1.cf.nosrc.rpm == {{{ [localhost ~]$ cd download [localhost download]$ wget http://mirror.city-fan.org/ftp/contrib/java/java-1.5.0-sun-1.5.0.22-1.1.cf.nosrc.rpm --2009-11-02 22:24:14-- http://mirror.city-fan.org/ftp/contrib/java/java-1.5.0-sun-1.5.0.22-1.1.cf.nosrc.rpm Resolving mirror.city-fan.org... 192.168.2.11 Connecting to mirror.city-fan.org|192.168.2.11|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 20199 (20K) [application/x-rpm] Saving to: `java-1.5.0-sun-1.5.0.22-1.1.cf.nosrc.rpm' 100%[======================================================>] 20,199 --.-K/s in 0.001s 2009-11-02 22:24:14 (19.3 MB/s) - `java-1.5.0-sun-1.5.0.22-1.1.cf.nosrc.rpm' saved [20199/20199] [localhost download]$ }}} == Build Java RPM Packages == {{{ [localhost download]$ rpmbuild --rebuild java-1.5.0-sun-1.5.0.22-1.1.cf.nosrc.rpm Installing java-1.5.0-sun-1.5.0.22-1.1.cf.nosrc.rpm warning: InstallSourcePackage: 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.28098 + umask 022 + cd /nis-home/phowarth/BUILD/BUILD + rm -rf /home/paul/rpmbuild/BUILD/jdk1.5.0_22 + export MORE=10000 + MORE=10000 + sh /home/paul/rpmbuild/SOURCES/jdk-1_5_0_22-linux-i586.bin ... omitted ... Wrote: /home/paul/rpmbuild/RPMS/i586/java-1.5.0-sun-1.5.0.22-1.1.cf.i586.rpm Wrote: /home/paul/rpmbuild/RPMS/i586/java-1.5.0-sun-devel-1.5.0.22-1.1.cf.i586.rpm Wrote: /home/paul/rpmbuild/RPMS/i586/java-1.5.0-sun-src-1.5.0.22-1.1.cf.i586.rpm Wrote: /home/paul/rpmbuild/RPMS/i586/java-1.5.0-sun-demo-1.5.0.22-1.1.cf.i586.rpm Wrote: /home/paul/rpmbuild/RPMS/i586/java-1.5.0-sun-plugin-1.5.0.22-1.1.cf.i586.rpm Wrote: /home/paul/rpmbuild/RPMS/i586/java-1.5.0-sun-fonts-1.5.0.22-1.1.cf.i586.rpm Wrote: /home/paul/rpmbuild/RPMS/i586/java-1.5.0-sun-alsa-1.5.0.22-1.1.cf.i586.rpm Wrote: /home/paul/rpmbuild/RPMS/i586/java-1.5.0-sun-jdbc-1.5.0.22-1.1.cf.i586.rpm Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.23655 + umask 022 + cd /home/paul/BUILD/BUILD + cd jdk1.5.0_15 + rm -rf /var/tmp/java-1.5.0-sun-1.5.0.22-1.1.cf-buildroot + exit 0 Executing(--clean): /bin/sh -e /var/tmp/rpm-tmp.67658 + umask 022 + cd /home/paul/rpmbuild/BUILD + rm -rf jdk1.5.0_22 + exit 0 [localhost download]$ }}} {i} To build the 32-bit versions of the package on a 64-bit machine, use: {{{ [localhost download]$ setarch i386 rpmbuild --rebuild java-1.5.0-sun-1.5.0.22-1.1.cf.nosrc.rpm }}} == Remove Any Old Cruft == If you have followed earlier versions of this or other guides that involved manually configuring the browser plugin in the `/usr/lib/mozilla/plugins` directory or ''Java Web Start'' as `/usr/bin/javaws`, remove these hacks: {{{ $ sudo rm -f /usr/lib/mozilla/plugins/libjavaplugin_oji.so /usr/bin/javaws }}} Neither of these are available for the `x86_64` architecture so this step is not necessary there. == Install Java Runtime Environment == It is not necessary to install ''all'' of the RPMs you have just built if you only need to run java applications and use the web plugin. For these applications, you only need the base package and the `fonts`, `alsa`, and `plugin` subpackages: {{{ [localhost ~]$ cd ~/rpmbuild/RPMS/i586/ [localhost i586]$ ls -1 java-1.5.0-sun-1.5.0.22-1.1.cf.i586.rpm java-1.5.0-sun-alsa-1.5.0.22-1.1.cf.i586.rpm java-1.5.0-sun-demo-1.5.0.22-1.1.cf.i586.rpm java-1.5.0-sun-devel-1.5.0.22-1.1.cf.i586.rpm java-1.5.0-sun-fonts-1.5.0.22-1.1.cf.i586.rpm java-1.5.0-sun-jdbc-1.5.0.22-1.1.cf.i586.rpm java-1.5.0-sun-plugin-1.5.0.22-1.1.cf.i586.rpm java-1.5.0-sun-src-1.5.0.22-1.1.cf.i586.rpm [localhost i586]$ sudo yum --nogpgcheck localinstall java-1.5.0-sun{,-alsa,-fonts,-plugin}-1.5.0*.rpm Setting up Local Package Process Examining java-1.5.0-sun-1.5.0.22-1.1.cf.i586.rpm: java-1.5.0-sun-1.5.0.22-1.1.cf.i586 Marking java-1.5.0-sun-1.5.0.22-1.1.cf.i586.rpm to be installed Examining java-1.5.0-sun-alsa-1.5.0.22-1.1.cf.i586.rpm: java-1.5.0-sun-alsa-1.5.0.22-1.1.cf.i586 Marking java-1.5.0-sun-alsa-1.5.0.22-1.1.cf.i586.rpm to be installed Examining java-1.5.0-sun-fonts-1.5.0.22-1.1.cf.i586.rpm: java-1.5.0-sun-fonts-1.5.0.22-1.1.cf.i586 Marking java-1.5.0-sun-fonts-1.5.0.22-1.1.cf.i586.rpm to be installed Examining java-1.5.0-sun-plugin-1.5.0.22-1.1.cf.i586.rpm: java-1.5.0-sun-plugin-1.5.0.22-1.1.cf.i586 Marking java-1.5.0-sun-plugin-1.5.0.22-1.1.cf.i586.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package java-1.5.0-sun.i586 0:1.5.0.22-1.1.cf set to be updated ---> Package java-1.5.0-sun-alsa.i586 0:1.5.0.22-1.1.cf set to be updated ---> Package java-1.5.0-sun-fonts.i586 0:1.5.0.22-1.1.cf set to be updated --> Processing Dependency: /usr/bin/ttmkfdir for package: java-1.5.0-sun-fonts-1.5.0.22-1.1.cf.i586 ---> Package java-1.5.0-sun-plugin.i586 0:1.5.0.22-1.1.cf set to be updated --> Running transaction check ---> Package ttmkfdir.i586 0:3.0.9-30.fc11 set to be updated --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================== Package Arch Version Repository Size ======================================================================================================== Installing: java-1.5.0-sun i586 1.5.0.22-1.1.cf /java-1.5.0-sun-1.5.0.22-1.1.cf.i586 85 M java-1.5.0-sun-alsa i586 1.5.0.22-1.1.cf /java-1.5.0-sun-alsa-1.5.0.22-1.1.cf.i586 66 k java-1.5.0-sun-fonts i586 1.5.0.22-1.1.cf /java-1.5.0-sun-fonts-1.5.0.22-1.1.cf.i586 2.0 M java-1.5.0-sun-plugin i586 1.5.0.22-1.1.cf /java-1.5.0-sun-plugin-1.5.0.22-1.1.cf.i586 1.7 M Installing for dependencies: ttmkfdir i586 3.0.9-30.fc11 fedora 46 k Transaction Summary ======================================================================================================== Install 5 Package(s) Upgrade 0 Package(s) Total size: 89 M Total download size: 46 k Is this ok [y/N]: y Downloading Packages: ttmkfdir-3.0.9-30.fc11.i586.rpm | 46 kB 00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : java-1.5.0-sun-1.5.0.22-1.1.cf.i586 1/5 Installing : ttmkfdir-3.0.9-30.fc11.i586 2/5 Installing : java-1.5.0-sun-plugin-1.5.0.22-1.1.cf.i586 3/5 Installing : java-1.5.0-sun-fonts-1.5.0.22-1.1.cf.i586 4/5 opendir: No such file or directory Installing : java-1.5.0-sun-alsa-1.5.0.22-1.1.cf.i586 5/5 Installed: java-1.5.0-sun.i586 0:1.5.0.22-1.1.cf java-1.5.0-sun-alsa.i586 0:1.5.0.22-1.1.cf java-1.5.0-sun-fonts.i586 0:1.5.0.22-1.1.cf java-1.5.0-sun-plugin.i586 0:1.5.0.22-1.1.cf Dependency Installed: ttmkfdir.i586 0:3.0.9-30.fc11 Complete! [localhost i586]$ }}} /!\ Note that the `java-1.5.0-sun-plugin` package is not available for the ''x86_64'' architecture, so use these commands instead on ''x86_64'': {{{ [localhost ~]$ cd ~/rpmbuild/RPMS/x86_64 [localhost x86_64]$ sudo yum --nogpgcheck localinstall java-1.5.0-sun{,-alsa,-fonts}-1.5.0*.rpm }}} == Install Java Development Environment == If you also want to build or develop Java applications yourself, install all of the RPM packages to get the full development environment. Skip this step if you only need the runtime environment from the previous step. {{{ [localhost i586]$ sudo yum --nogpgcheck localinstall java-1.5.0-sun*.rpm Setting up Local Package Process Examining java-1.5.0-sun-1.5.0.22-1.1.cf.i586.rpm: java-1.5.0-sun-1.5.0.22-1.1.cf.i586 java-1.5.0-sun-1.5.0.22-1.1.cf.i586.rpm: does not update installed package. Examining java-1.5.0-sun-alsa-1.5.0.22-1.1.cf.i586.rpm: java-1.5.0-sun-alsa-1.5.0.22-1.1.cf.i586 java-1.5.0-sun-alsa-1.5.0.22-1.1.cf.i586.rpm: does not update installed package. Examining java-1.5.0-sun-demo-1.5.0.22-1.1.cf.i586.rpm: java-1.5.0-sun-demo-1.5.0.22-1.1.cf.i586 Marking java-1.5.0-sun-demo-1.5.0.22-1.1.cf.i586.rpm to be installed updates-local | 2.3 kB 00:00 city-fan.org | 2.3 kB 00:00 Examining java-1.5.0-sun-devel-1.5.0.22-1.1.cf.i586.rpm: java-1.5.0-sun-devel-1.5.0.22-1.1.cf.i586 Marking java-1.5.0-sun-devel-1.5.0.22-1.1.cf.i586.rpm to be installed Examining java-1.5.0-sun-fonts-1.5.0.22-1.1.cf.i586.rpm: java-1.5.0-sun-fonts-1.5.0.22-1.1.cf.i586 java-1.5.0-sun-fonts-1.5.0.22-1.1.cf.i586.rpm: does not update installed package. Examining java-1.5.0-sun-jdbc-1.5.0.22-1.1.cf.i586.rpm: java-1.5.0-sun-jdbc-1.5.0.22-1.1.cf.i586 Marking java-1.5.0-sun-jdbc-1.5.0.22-1.1.cf.i586.rpm to be installed Examining java-1.5.0-sun-plugin-1.5.0.22-1.1.cf.i586.rpm: java-1.5.0-sun-plugin-1.5.0.22-1.1.cf.i586 java-1.5.0-sun-plugin-1.5.0.22-1.1.cf.i586.rpm: does not update installed package. Examining java-1.5.0-sun-src-1.5.0.22-1.1.cf.i586.rpm: java-1.5.0-sun-src-1.5.0.22-1.1.cf.i586 Marking java-1.5.0-sun-src-1.5.0.22-1.1.cf.i586.rpm to be installed Resolving Dependencies --> Running transaction check ---> Package java-1.5.0-sun-demo.i586 0:1.5.0.22-1.1.cf set to be updated ---> Package java-1.5.0-sun-devel.i586 0:1.5.0.22-1.1.cf set to be updated ---> Package java-1.5.0-sun-jdbc.i586 0:1.5.0.22-1.1.cf set to be updated --> Processing Dependency: /usr/lib/libodbc.so for package: java-1.5.0-sun-jdbc-1.5.0.22-1.1.cf.i586 Importing additional filelist information --> Processing Dependency: /usr/lib/libodbcinst.so for package: java-1.5.0-sun-jdbc-1.5.0.22-1.1.cf.i586 ---> Package java-1.5.0-sun-src.i586 0:1.5.0.22-1.1.cf set to be updated --> Running transaction check ---> Package unixODBC.i586 0:2.2.14-2.fc11 set to be updated --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================== Package Arch Version Repository Size ======================================================================================================== Installing: java-1.5.0-sun-demo i586 1.5.0.22-1.1.cf /java-1.5.0-sun-demo-1.5.0.22-1.1.cf.i586 14 M java-1.5.0-sun-devel i586 1.5.0.22-1.1.cf /java-1.5.0-sun-devel-1.5.0.22-1.1.cf.i586 11 M java-1.5.0-sun-jdbc i586 1.5.0.22-1.1.cf /java-1.5.0-sun-jdbc-1.5.0.22-1.1.cf.i586 58 k java-1.5.0-sun-src i586 1.5.0.22-1.1.cf /java-1.5.0-sun-src-1.5.0.22-1.1.cf.i586 17 M Installing for dependencies: unixODBC i586 2.2.14-2.fc11 fedora 475 k Transaction Summary ======================================================================================================== Install 5 Package(s) Upgrade 0 Package(s) Total size: 43 M Total download size: 475 k Is this ok [y/N]: y Downloading Packages: unixODBC-2.2.14-2.fc11.i586.rpm | 475 kB 00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : unixODBC-2.2.14-2.fc11.i586 1/5 Installing : java-1.5.0-sun-jdbc-1.5.0.22-1.1.cf.i586 2/5 Installing : java-1.5.0-sun-src-1.5.0.22-1.1.cf.i586 3/5 Installing : java-1.5.0-sun-demo-1.5.0.22-1.1.cf.i586 4/5 Installing : java-1.5.0-sun-devel-1.5.0.22-1.1.cf.i586 5/5 Installed: java-1.5.0-sun-demo.i586 0:1.5.0.22-1.1.cf java-1.5.0-sun-devel.i586 0:1.5.0.22-1.1.cf java-1.5.0-sun-jdbc.i586 0:1.5.0.22-1.1.cf java-1.5.0-sun-src.i586 0:1.5.0.22-1.1.cf Dependency Installed: unixODBC.i586 0:2.2.14-2.fc11 Complete! [localhost i586]$ }}} == Check Java Version == {{{ [localhost i586]$ java -version java version "1.5.0_22" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03) Java HotSpot(TM) Client VM (build 1.5.0_22-b03, mixed mode) [localhost i586]$ }}} {i} On Fedora 8 and later releases, the default java implementation will still be !IcedTea at this point; see ''Switching Between Java Implementations'' below for how to change this if you want to do so. == Switching Between Java Implementations == The JPackage java RPMs support switching between java implementations using the ''alternatives'' system. {{{ [localhost ~]$ sudo /usr/sbin/alternatives --config java There is 2 program that provides 'java'. Selection Command ----------------------------------------------- *+ 1 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java 2 /usr/lib/jvm/jre-1.5.0-sun/bin/java Enter to keep the current selection[+], or type selection number: 2 [localhost ~]$ java -version java version "1.5.0_22" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_22-b03) Java HotSpot(TM) Client VM (build 1.5.0_22-b03, mixed mode) [localhost ~]$ sudo /usr/sbin/alternatives --auto java [localhost ~]$ java -version java version "1.6.0_0" OpenJDK Runtime Environment (IcedTea6 1.5) (fedora-27.b16.fc11-i386) OpenJDK Client VM (build 14.0-b15, mixed mode) }}} A separate ''alternatives'' setting is used for the browser plugin (not available on ''x86_64''): {{{ [localhost ~]$ sudo /usr/sbin/alternatives --config libjavaplugin.so There is 2 program that provides 'libjavaplugin.so'. Selection Command ----------------------------------------------- *+ 1 /usr/lib/jvm/jre-1.6.0-openjdk/lib/i386/IcedTeaPlugin.so 2 /usr/lib/jvm/jre-1.5.0-sun/plugin/i386/ns7/libjavaplugin_oji.so Enter to keep the current selection[+], or type selection number: 2 }}} There are other less-used ''alternatives'' settings that can also be tweaked; if you're not a Java developer then it's unlikely you'll need to change any of these: * `jce_1.5.0_sun_local_policy` * `jre_sun` * `jre_1.5.0` * `javac` (if you've installed `java-1.5.0-sun-devel`) * `java_sdk_sun` (if you've installed `java-1.5.0-sun-devel`) * `java_sdk_1.5.0` (if you've installed `java-1.5.0-sun-devel`) == References == * FedoraProject:JavaFAQ * http://www.jpackage.org/rebuilding.php * http://jpackage.org/faq.php * http://liquidat.wordpress.com/2007/06/11/howto-sun-java-web-start-on-fedora-7/ ---- CategoryTip