= JPackage Java for Fedora = For Fedora 7 onwards, this article is superseded by SunJava5OnFedora and SunJava6OnFedora. Here are step-by-step instructions for building Java packages from [[http://jpackage.org|jpackage.org]] for Fedora 8 based on the Java Package Recommendations in the [[http://fedora.redhat.com/docs/release-notes/fc4/errata/|Fedora Core 4 Release Notes]]: '''6.1.8. Java Package Recommendations''' ''Fedora Core 4 users are advised not to use the Java RPM provided by Sun. It contains Provides that conflict with names used in packages provided as part of Fedora Core 4. Because of this, Sun Java might disappear from an installed system during package upgrade operations. Fedora Core 4 users should use either the RPM from jpackage.org or manually install the Sun Java tarball into /opt. Sun Java 1.5+ is recommended for stability purposes.'' {i} The quote above is from the Fedora Core 4 release notes but the same issues affect later releases too. The steps shown in this guide are tested on Fedora 8 (i386) but the same process works on other releases. For the ''x86_64'' architecture, download the `x86_64` file instead of the `i586` file from the Sun website. These instructions should also work for similar distributions such as CentOS. Note that Red Hat Enterprise Linux includes pre-built binary packages for Sun java, which are available in separate channels (e.g. the ''RHEL Supplementary'' channel for RHEL 5). == 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. == Install jpackage.repo from JPackage == {i} This step is optional. The rest of the procedure will work without configuring the [[http://jpackage.org/|JPackage]] repository, but it may be worth doing this because it gives you access, via `yum` or a GUI package manager built on `yum` such as `yumex`, to a large number of nicely-packaged Java applications to go with your Java installation. However, bear in mind the following caution from the [[http://fedora.redhat.com/docs/release-notes/fc5/release-notes-ISO/|Fedora Core 5 Release Notes]]: '''15.2. Fedora and the JPackage Java Packages'''<
> Fedora Core includes many packages derived from the JPackage Project, which provides a Java software repository. These packages have been modified in Fedora to remove proprietary software dependencies and to make use of GCJ's ahead-of-time compilation feature. Fedora users should use the Fedora repositories for updates to these packages, and may use the JPackage repository for packages not provided by Fedora. Refer to the JPackage website at http://jpackage.org for more information on the project and the software that it provides. || /!\ '''Mixing Packages from Fedora and JPackage'''<
><
>Research package compatibility before you install software from both the Fedora and JPackage repositories on the same system. Incompatible packages may cause complex issues.|| {{{ [localhost ~]$ cd /etc/yum.repos.d/ [localhost yum.repos.d]$ sudo wget http://www.jpackage.org/jpackage.repo --11:38:19-- http://www.jpackage.org/jpackage.repo => `jpackage.repo' Resolving www.jpackage.org... 212.85.153.228 Connecting to www.jpackage.org[212.85.153.228]:80... connected. HTTP request sent, awaiting response... 200 OK Length: 629 [text/plain] 100%[======================================================>] 629 --.--K/s 11:38:20 (1.30 MB/s) - `jpackage.repo' saved [629/629] [localhost yum.repos.d]$}}} == Download jdk-1_5_0_14-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 14'' 1. Click on ''Accept License Agreement'' 1. Download {{{ jdk-1_5_0_14-linux-i586.bin}}} by clicking on ''Linux self-extracting file'' in the box labelled ''Linux Platform - J2SE(TM) Development Kit 5.0 Update 14'' /!\ For installs on ''x86_64'' systems, download `jdk-1_5_0_14-linux-amd64.bin` by clicking on ''Linux x64 RPM in self-extracting file (use 32-bit version for applet and Java Web Start support)'' in the box labelled ''Linux x64 Platform - J2SE(TM) Development Kit 5.0 Update 14'' == Copy jdk-1_5_0_14-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_14-linux-i586.bin [localhost download]$ cp jdk-1_5_0_14-linux-i586.bin ~/rpmbuild/SOURCES/ [localhost download]$ }}} /!\ For installs on ''x86_64'' systems, the filename is of course `jdk-1_5_0_14-linux-amd64.bin` == Download java-1.5.0-sun-1.5.0.14-1jpp.nosrc.rpm from JPackage == {{{ [localhost ~]$ cd download [localhost download]$ wget http://mirrors.dotsrc.org/jpackage/1.7/generic/non-free/SRPMS/java-1.5.0-sun-1.5.0.14-1jpp.nosrc.rpm --15:47:24-- http://mirrors.dotsrc.org/jpackage/1.7/generic/non-free/SRPMS/java-1.5.0-sun-1.5.0.14-1jpp.nosrc.rpm => `java-1.5.0-sun-1.5.0.14-1jpp.nosrc.rpm' Resolving mirrors.dotsrc.org... 130.225.254.103, 130.225.254.99 Connecting to mirrors.dotsrc.org|130.225.254.103|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 17,699 (17K) [application/x-redhat-package-manager] 100%[==================================================================================>] 17,699 --.--K/s 15:47:24 (147.12 KB/s) - `java-1.5.0-sun-1.5.0.14-1jpp.nosrc.rpm' saved [17699/17699] [localhost download]$ }}} == Build Java RPM Packages == For Fedora 7 and later releases, some edits are needed to the RPM spec file to fix some outdated directory locations. The same edits are needed for CentOS 5 too. * Unpack the RPM: . {{{ [localhost download]$ rpm -Uvh java-1.5.0-sun-1.5.0.14-1jpp.nosrc.rpm }}} * Edit `~/rpmbuild/SPECS/java-1.5.0-sun.spec` and change the two lines: . {{{ %define x11bindir %{_prefix}/X11R6/bin %define x11encdir %{_prefix}/X11R6/lib/X11/fonts/encodings }}} . to: . {{{ %define x11bindir %{_prefix}/bin %define x11encdir %{_prefix}/share/X11/fonts/encodings }}} * Rebuild `java-1.5.0-sun-1.5.0.14-1jpp.nosrc.rpm` with the edits: . {{{ [localhost download]$ rpmbuild -bs ~/rpmbuild/SPECS/java-1.5.0-sun.spec Wrote: /home/paul/rpmbuild/SRPMS/java-1.5.0-sun-1.5.0.14-1jpp.nosrc.rpm [localhost download]$ mv ~/rpmbuild/SRPMS/java-1.5.0-sun-1.5.0.14-1jpp.nosrc.rpm . }}} The binary RPM packages can now be built: {{{ [localhost download]$ rpmbuild --rebuild java-1.5.0-sun-1.5.0.14-1jpp.nosrc.rpm Installing java-1.5.0-sun-1.5.0.14-1jpp.nosrc.rpm warning: InstallSourcePackage: Header V3 DSA signature: NOKEY, key ID c431416d warning: user jasonc does not exist - using root warning: group jasonc does not exist - using root warning: user jasonc does not exist - using root warning: group jasonc does not exist - using root warning: user jasonc does not exist - using root warning: group jasonc does not exist - using root Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.7654 + umask 022 + cd /home/paul/rpmbuild/BUILD + rm -rf /home/paul/rpmbuild/BUILD/jdk1.5.0_09 + export MORE=10000 + MORE=10000 + sh /home/paul/rpmbuild/SOURCES/jdk-1_5_0_14-linux-i586.bin ... omitted ... Wrote: /home/paul/rpmbuild/RPMS/i586/java-1.5.0-sun-1.5.0.14-1jpp.i586.rpm Wrote: /home/paul/rpmbuild/RPMS/i586/java-1.5.0-sun-devel-1.5.0.14-1jpp.i586.rpm Wrote: /home/paul/rpmbuild/RPMS/i586/java-1.5.0-sun-src-1.5.0.14-1jpp.i586.rpm Wrote: /home/paul/rpmbuild/RPMS/i586/java-1.5.0-sun-demo-1.5.0.14-1jpp.i586.rpm Wrote: /home/paul/rpmbuild/RPMS/i586/java-1.5.0-sun-plugin-1.5.0.14-1jpp.i586.rpm Wrote: /home/paul/rpmbuild/RPMS/i586/java-1.5.0-sun-fonts-1.5.0.14-1jpp.i586.rpm Wrote: /home/paul/rpmbuild/RPMS/i586/java-1.5.0-sun-alsa-1.5.0.14-1jpp.i586.rpm Wrote: /home/paul/rpmbuild/RPMS/i586/java-1.5.0-sun-jdbc-1.5.0.14-1jpp.i586.rpm Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.23655 + umask 022 + cd /home/paul/BUILD/BUILD + cd jdk1.5.0_14 + rm -rf /var/tmp/java-1.5.0-sun-1.5.0.14-1jpp-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_14 + exit 0 [localhost download]$}}} == 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.14-1jpp.i586.rpm java-1.5.0-sun-alsa-1.5.0.14-1jpp.i586.rpm java-1.5.0-sun-demo-1.5.0.14-1jpp.i586.rpm java-1.5.0-sun-devel-1.5.0.14-1jpp.i586.rpm java-1.5.0-sun-fonts-1.5.0.14-1jpp.i586.rpm java-1.5.0-sun-jdbc-1.5.0.14-1jpp.i586.rpm java-1.5.0-sun-plugin-1.5.0.14-1jpp.i586.rpm java-1.5.0-sun-src-1.5.0.14-1jpp.i586.rpm [localhost i586]$ (echo config gpgcheck 0; echo localinstall java-1.5.0-sun{,-alsa,-fonts,-plugin}-1.5.0*.rpm; echo run) > yum-cmd [localhost i586]$ sudo yum shell yum-cmd Loading "installonlyn" plugin Setting up Yum Shell Setting up Local Package Process Examining java-1.5.0-sun-1.5.0.09-1jpp.i586.rpm: java-1.5.0-sun - 1.5.0.07-1jpp.i586 Examining java-1.5.0-sun-alsa-1.5.0.09-1jpp.i586.rpm: java-1.5.0-sun-alsa - 1.5.0.07-1jpp.i586 Examining java-1.5.0-sun-fonts-1.5.0.09-1jpp.i586.rpm: java-1.5.0-sun-fonts - 1.5.0.07-1jpp.i586 Examining java-1.5.0-sun-plugin-1.5.0.09-1jpp.i586.rpm: java-1.5.0-sun-plugin - 1.5.0.07-1jpp.i586 Marking java-1.5.0-sun-1.5.0.09-1jpp.i586.rpm to be installed Marking java-1.5.0-sun-alsa-1.5.0.14-1jpp.i586.rpm to be installed Marking java-1.5.0-sun-fonts-1.5.0.14-1jpp.i586.rpm to be installed Marking java-1.5.0-sun-plugin-1.5.0.14-1jpp.i586.rpm to be installed --> Running transaction check ---> Package java-1.5.0-sun-fonts.i586 0:1.5.0.14-1jpp set to be updated --> Processing Dependency: /usr/sbin/chkfontpath for package: java-1.5.0-sun-fonts ---> Package java-1.5.0-sun.i586 0:1.5.0.14-1jpp set to be updated --> Processing Dependency: libXp.so.6 for package: java-1.5.0-sun ---> Package java-1.5.0-sun-alsa.i586 0:1.5.0.14-1jpp set to be updated ---> Package java-1.5.0-sun-plugin.i586 0:1.5.0.14-1jpp set to be updated --> Running transaction check ---> Package libXp.i386 0:1.0.0-8.fc8 set to be updated ---> Package chkfontpath.i386 0:1.10.1-2.fc8 set to be updated --> Finished Dependency Resolution ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: java-1.5.0-sun-alsa i586 1.5.0.14-1jpp java-1.5.0-sun-alsa-1.5.0.14-1jpp.i586.rpm 66 k java-1.5.0-sun-fonts i586 1.5.0.14-1jpp java-1.5.0-sun-fonts-1.5.0.14-1jpp.i586.rpm 2.0 M java-1.5.0-sun-plugin i586 1.5.0.14-1jpp java-1.5.0-sun-plugin-1.5.0.14-1jpp.i586.rpm 1.7 M Installing for dependencies: chkfontpath i386 1.10.1-2.fc8 fedora 15 k java-1.5.0-sun i586 1.5.0.14-1jpp java-1.5.0-sun-1.5.0.14-1jpp.i586.rpm 85 M libXp i386 1.0.0-8.fc8 fedora 22 k Transaction Summary ============================================================================= Install 6 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 88 M Is this ok [y/N]: y Downloading Packages: (1/2): chkfontpath-1.10.1 100% |=========================| 15 kB 00:00 (2/2): libXp-1.0.0-8.fc8. 100% |=========================| 22 kB 00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: chkfontpath ######################### [1/6] Installing: libXp ######################### [2/6] Installing: java-1.5.0-sun ######################### [3/6] Installing: java-1.5.0-sun-plugin ######################### [4/6] Installing: java-1.5.0-sun-fonts ######################### [5/6] opendir: No such file or directory Installing: java-1.5.0-sun-alsa ######################### [6/6] Installed: java-1.5.0-sun-alsa.i586 0:1.5.0.14-1jpp java-1.5.0-sun-fonts.i586 0:1.5.0.14-1jpp java-1.5.0-sun-plugin.i586 0:1.5.0.14-1jpp Dependency Installed: chkfontpath.i386 0:1.10.1-2.fc8 java-1.5.0-sun.i586 0:1.5.0.14-1jpp libXp.i386 0:1.0.0-8.fc8 Finished Transaction Leaving Shell [localhost i586]$ rm yum-cmd [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]$ (echo config gpgcheck 0; echo localinstall java-1.5.0-sun{,-alsa,-fonts}-1.5.0*.rpm; echo run) > yum-cmd [localhost x86_64]$ sudo yum shell yum-cmd [localhost x86_64]$ rm yum-cmd}}} == 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]$ (echo config gpgcheck 0; echo localinstall java-1.5.0-sun*.rpm; echo run) > yum-cmd [localhost i586]$ sudo yum shell yum-cmd Setting up Yum Shell Setting up Local Package Process Examining java-1.5.0-sun-1.5.0.14-1jpp.i586.rpm: java-1.5.0-sun - 1.5.0.14-1jpp.i586 Examining java-1.5.0-sun-alsa-1.5.0.14-1jpp.i586.rpm: java-1.5.0-sun-alsa - 1.5.0.14-1jpp.i586 Examining java-1.5.0-sun-demo-1.5.0.14-1jpp.i586.rpm: java-1.5.0-sun-demo - 1.5.0.14-1jpp.i586 Examining java-1.5.0-sun-devel-1.5.0.14-1jpp.i586.rpm: java-1.5.0-sun-devel - 1.5.0.14-1jpp.i586 Examining java-1.5.0-sun-fonts-1.5.0.14-1jpp.i586.rpm: java-1.5.0-sun-fonts - 1.5.0.14-1jpp.i586 Examining java-1.5.0-sun-jdbc-1.5.0.14-1jpp.i586.rpm: java-1.5.0-sun-jdbc - 1.5.0.14-1jpp.i586 Examining java-1.5.0-sun-plugin-1.5.0.14-1jpp.i586.rpm: java-1.5.0-sun-plugin - 1.5.0.14-1jpp.i586 Examining java-1.5.0-sun-src-1.5.0.14-1jpp.i586.rpm: java-1.5.0-sun-src - 1.5.0.14-1jpp.i586 Marking java-1.5.0-sun-demo-1.5.0.14-1jpp.i586.rpm to be installed Marking java-1.5.0-sun-devel-1.5.0.14-1jpp.i586.rpm to be installed Marking java-1.5.0-sun-jdbc-1.5.0.14-1jpp.i586.rpm to be installed Marking java-1.5.0-sun-src-1.5.0.14-1jpp.i586.rpm to be installed java-1.5.0-sun-1.5.0.14-1jpp.i586.rpm: does not update installed package. java-1.5.0-sun-alsa-1.5.0.14-1jpp.i586.rpm: does not update installed package. java-1.5.0-sun-fonts-1.5.0.14-1jpp.i586.rpm: does not update installed package. java-1.5.0-sun-plugin-1.5.0.14-1jpp.i586.rpm: does not update installed package. --> Running transaction check ---> Package java-1.5.0-sun-jdbc.i586 0:1.5.0.14-1jpp set to be updated --> Processing Dependency: /usr/lib/libodbc.so for package: java-1.5.0-sun-jdbc Importing additional filelist information --> Processing Dependency: /usr/lib/libodbcinst.so for package: java-1.5.0-sun-jdbc ---> Package java-1.5.0-sun-src.i586 0:1.5.0.14-1jpp set to be updated ---> Package java-1.5.0-sun-devel.i586 0:1.5.0.14-1jpp set to be updated ---> Package java-1.5.0-sun-demo.i586 0:1.5.0.14-1jpp set to be updated --> Running transaction check ---> Package unixODBC.i386 0:2.2.12-5.fc8 set to be updated ---> Package unixODBC-devel.i386 0:2.2.12-5.fc8 set to be updated --> Finished Dependency Resolution ============================================================================= Package Arch Version Repository Size ============================================================================= Installing: java-1.5.0-sun-demo i586 1.5.0.14-1jpp java-1.5.0-sun-demo-1.5.0.14-1jpp.i586.rpm 14 M java-1.5.0-sun-devel i586 1.5.0.14-1jpp java-1.5.0-sun-devel-1.5.0.14-1jpp.i586.rpm 11 M java-1.5.0-sun-jdbc i586 1.5.0.14-1jpp java-1.5.0-sun-jdbc-1.5.0.14-1jpp.i586.rpm 58 k java-1.5.0-sun-src i586 1.5.0.14-1jpp java-1.5.0-sun-src-1.5.0.14-1jpp.i586.rpm 17 M Installing for dependencies: unixODBC i386 2.2.12-5.fc8 local-updates 954 k unixODBC-devel i386 2.2.12-5.fc8 updates 920 k Transaction Summary ============================================================================= Install 6 Package(s) Update 0 Package(s) Remove 0 Package(s) Total download size: 44 M Is this ok [y/N]: y Downloading Packages: (1/2): unixODBC-devel-2.2 100% |=========================| 920 kB 00:01 (2/2): unixODBC-2.2.12-5. 100% |=========================| 954 kB 00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing: unixODBC ######################### [1/6] Installing: unixODBC-devel ######################### [2/6] Installing: java-1.5.0-sun-devel ######################### [3/6] Installing: java-1.5.0-sun-jdbc ######################### [4/6] Installing: java-1.5.0-sun-src ######################### [5/6] Installing: java-1.5.0-sun-demo ######################### [6/6] Installed: java-1.5.0-sun-demo.i586 0:1.5.0.14-1jpp java-1.5.0-sun-devel.i586 0:1.5.0.14-1jpp java-1.5.0-sun-jdbc.i586 0:1.5.0.14-1jpp java-1.5.0-sun-src.i586 0:1.5.0.14-1jpp Dependency Installed: unixODBC.i386 0:2.2.12-5.fc8 unixODBC-devel.i386 0:2.2.12-5.fc8 Finished Transaction Leaving Shell [localhost i586]$ rm yum-cmd [localhost i586]$}}} == Check Java Version == {{{ [localhost i586]$ java -version java version "1.5.0_14" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03) Java HotSpot(TM) Client VM (build 1.5.0_14-b03, mixed mode, sharing) [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. == Firefox/Mozilla Plugin == If you've installed `java-1.5.0-sun-plugin` and you want to use it with Firefox or any other mozilla-based browser, you'll need to set up the link manually as there is a small bug in the {{{ java-1.5.0-sun-plugin}}} package that causes it not to set up the link properly. {{{ [localhost i586]$ cd /usr/lib/mozilla/plugins [localhost plugins]$ sudo rm -f libjavaplugin_oji.so [localhost plugins]$ sudo ln -s ../../../lib/jvm/java/jre/plugin/i386/ns7/libjavaplugin_oji.so .}}} Removing any existing `libjavaplugin_oji.so` link should only be necessary if you've previously installed a different version of java. /!\ Note that the browser plugin is not available for the ''x86_64'' architecture == 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 are 3 programs which provide 'java'. Selection Command ----------------------------------------------- *+ 1 /usr/lib/jvm/jre-1.7.0-icedtea/bin/java 2 /usr/lib/jvm/jre-1.5.0-gcj/bin/java 3 /usr/lib/jvm/jre-1.5.0-sun/bin/java Enter to keep the current selection[+], or type selection number: 3 [localhost ~]$ java -version java version "1.5.0_14" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_14-b03) Java HotSpot(TM) Client VM (build 1.5.0_14-b03, mixed mode, sharing) [localhost ~]$ sudo /usr/sbin/alternatives --auto java [localhost ~]$ java -version java version "1.7.0" IcedTea Runtime Environment (build 1.7.0-b21) IcedTea Client VM (build 1.7.0-b21, mixed mode) }}} == Java Web Start == The Java Web Start binary - `javaws` - is included in the `java-1.5.0-sun-devel` package, but for reasons I have not yet fathomed, is not one of the binaries handled by the alternatives system in the JPackage RPMs. So if you need to use `javaws`, you'll need to set it up manually. {{{ $ sudo /usr/sbin/alternatives --install /usr/bin/javaws javaws /usr/lib/jvm/java-1.5.0-sun-1.5.0.14/jre/bin/javaws 1 }}} You'll also want to register the MIME type `application/x-java-jnlp-file` with the binary `/usr/bin/javaws` in your browser. How you do this is browser-specific. For example, in Firefox you can browse to a URL of that type such as the [[http://dist.trolltech.com/developer/download/webstart/qtjambi.jnlp|Qt Jambi web demo]] and when prompted for which helper application to use to open the file, select "Other" and then select `/usr/bin/javaws` from the file chooser that appears. == 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