You are not allowed to use this action.

Clear message

    OracleJava7OnFedora

Oracle Java 7 on Fedora

This guide is based on my previous SunJava6OnFedora one for Sun (Oracle) Java SE 6, and provides an installation method that is compatible with the JPackage conventions used by Fedora, Red Hat and compatible distributions.

Fedora currently includes OpenJDK version 8, which is the free equivalent of Java SE 8, but some old applications may not run on Java 8, or OpenJDK 7, hence this guide may prove useful to some people. I have tested the x86_64 version on Fedora 21 with the EMC NetWorker Management Console (version 7.6.2.7 is the earliest release that supports Java SE 7u1 onwards), which gives me a fair degree of confidence in it. I believe it should work on older releases down to Fedora 7 and even CentOS 5 too.

/!\ Since Java 7 Update 51, NetWorker versions prior to 8.1.1 need to have their Management Console URL added to the Exception Sites List on the Security tab of the Java Control Panel (ControlPanel); see https://community.emc.com/thread/184727

Create RPM Build Environment

If you have not built RPM packages using your regular user account (not root) before, you should create an RPM build environment for your account before going any further.

Download jdk-7u80-linux-x64.tar.gz from Oracle

  1. Go to http://www.oracle.com/technetwork/java/javase/downloads/index.html

  2. Click on the JDK Download button for Java SE 7u80

  3. You need to accept the Oracle Binary Code License Agreement for Java SE before continuing

  4. Download the Linux x64 - Compressed Binary (jdk-7u80-linux-x64.tar.gz), or on 32-bit systems, Linux x86 - Compressed Binary (jdk-7u80-linux-i586.tar.gz)

Download the Timezone Updater from Oracle

  1. Go to http://www.oracle.com/technetwork/java/javase/downloads/index.html

  2. Click on the Download button for JDK Timezone Updater Tool - 2.0.0

  3. Check the box agreeing to the Java SE Timezone Updater License Agreement

  4. Download the Java SE Timezone Updater 2.0.0 (tzupdater-2_0_0-2015a.zip)

Download the JCE Unlimited Strength Jurisdiction Policy from Oracle

  1. Go to http://www.oracle.com/technetwork/java/javase/downloads/index.html

  2. Click on the Download button for Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files for JDK/JRE 7

  3. Check the box agreeing to the Oracle Binary Code License Agreement for the Java SE Platform Products

  4. Download the Java Cryptography Extension (UnlimitedJCEPolicyJDK7.zip)

Copy Downloaded Files to SOURCES

{i} You might have a different download directory for your browser.

[localhost ~]$ cd download/
[localhost download]$ ls
jdk-7u80-linux-x64.tar.gz tzupdater-2_0_0-2015a.zip UnlimitedJCEPolicyJDK7.zip
[localhost download]$ cp -p jdk-7u80-linux-x64.tar.gz tzupdater-2_0_0-2015a.zip UnlimitedJCEPolicyJDK7.zip ~/rpmbuild/SOURCES/
[localhost download]$

/!\ For installs on 32-bit systems, the JDK filename is of course jdk-7u80-linux-i586.tar.gz

Download java-1.7.0-oracle-1.7.0.80-1.0.cf.nosrc.rpm

Since Sun has been swallowed by Oracle, I decided to call this package java-1.7.0-oracle rather than java-1.7.0-sun.

[localhost ~]$ cd download
[localhost download]$ wget http://mirror.city-fan.org/ftp/contrib/java/java-1.7.0-oracle-1.7.0.80-1.0.cf.nosrc.rpm
$ wget http://mirror.city-fan.org/ftp/contrib/java/java-1.7.0-oracle-1.7.0.80-1.0.cf.nosrc.rpm
--2015-04-15 10:00:00--  http://mirror.city-fan.org/ftp/contrib/java/java-1.7.0-oracle-1.7.0.80-1.0.cf.nosrc.rpm
Resolving mirror.city-fan.org... 212.56.100.58
Connecting to mirror.city-fan.org|212.56.100.58|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 283335 (277K) [application/x-rpm]
Saving to: ‘java-1.7.0-oracle-1.7.0.80-1.0.cf.nosrc.rpm’

100%[============================================================================================>] 283,335      253KB/s   in 1.1s

2015-04-15 10:00:00 (253 KB/s) - ‘java-1.7.0-oracle-1.7.0.80-1.0.cf.nosrc.rpm’ saved [283335/283335]

[localhost download]$

Build Java RPM Packages

[localhost download]$ export QA_RPATHS=$[ 0x0001 ]
[localhost download]$ rpmbuild --rebuild java-1.7.0-oracle-1.7.0.80-1.0.cf.nosrc.rpm
Installing java-1.7.0-oracle-1.7.0.80-1.0.cf.nosrc.rpm
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.luenZS
+ umask 022
+ cd /home/paul/rpmbuild/BUILD
+ LANG=C
+ export LANG
+ unset DISPLAY
+ cd /home/paul/rpmbuild/BUILD
+ rm -rf jdk1.7.0_80
+ /usr/bin/gzip -dc /home/paul/rpmbuild/SOURCES/jdk-7u80-linux-x64.tar.gz
+ /bin/tar -xf -
+ STATUS=0
...
omitted
...
Wrote: /home/paul/rpmbuild/RPMS/x86_64/java-1.7.0-oracle-1.7.0.80-1.0.cf.x86_64.rpm
Wrote: /home/paul/rpmbuild/RPMS/x86_64/java-1.7.0-oracle-devel-1.7.0.80-1.0.cf.x86_64.rpm
Wrote: /home/paul/rpmbuild/RPMS/x86_64/java-1.7.0-oracle-src-1.7.0.80-1.0.cf.x86_64.rpm
Wrote: /home/paul/rpmbuild/RPMS/x86_64/java-1.7.0-oracle-plugin-1.7.0.80-1.0.cf.x86_64.rpm
Wrote: /home/paul/rpmbuild/RPMS/x86_64/java-1.7.0-oracle-jdbc-1.7.0.80-1.0.cf.x86_64.rpm
Wrote: /home/paul/rpmbuild/RPMS/x86_64/java-1.7.0-oracle-javafx-1.7.0.80-1.0.cf.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.JcqYx6
+ umask 022
+ cd /home/paul/rpmbuild/BUILD/java-1.7.0-oracle
+ cd jdk1.7.0_80
+ rm -rf /home/paul/rpmbuild/BUILDROOT/java-1.7.0-oracle-1.7.0.80-1.0.cf.x86_64
+ 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.7.0-oracle-1.7.0.80-1.0.cf.nosrc.rpm

You will need the 32-bit version of glibc for this.

{i} The QA_RPATHS setting allows the build to succeed for advanced users with check-rpaths in their RPM-building configuration

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

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 plugin subpackage:

[localhost ~]$ cd ~/rpmbuild/RPMS/x86_64/
[localhost x86_64]$ ls -1
java-1.7.0-oracle-1.7.0.80-1.0.cf.x86_64.rpm
java-1.7.0-oracle-devel-1.7.0.80-1.0.cf.x86_64.rpm
java-1.7.0-oracle-javafx-1.7.0.80-1.0.cf.x86_64.rpm
java-1.7.0-oracle-jdbc-1.7.0.80-1.0.cf.x86_64.rpm
java-1.7.0-oracle-plugin-1.7.0.80-1.0.cf.x86_64.rpm
java-1.7.0-oracle-src-1.7.0.80-1.0.cf.x86_64.rpm
[localhost x86_64]$ sudo yum --nogpgcheck localinstall java-1.7.0-oracle{,-plugin}-1.7.0*.rpm
Loaded plugins: langpacks, presto, refresh-packagekit
Setting up Local Package Process
Examining java-1.7.0-oracle-1.7.0.80-1.0.cf.x86_64.rpm: java-1.7.0-oracle-1.7.0.80-1.0.cf.x86_64
Marking java-1.7.0-oracle-1.7.0.80-1.0.cf.x86_64.rpm to be installed
Examining java-1.7.0-oracle-plugin-1.7.0.80-1.0.cf.x86_64.rpm: java-1.7.0-oracle-plugin-1.7.0.80-1.0.cf.x86_64
Marking java-1.7.0-oracle-plugin-1.7.0.80-1.0.cf.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package java-1.7.0-oracle.x86_64 0:1.7.0.80-1.0.cf will be installed
---> Package java-1.7.0-oracle-plugin.x86_64 0:1.7.0.80-1.0.cf will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================
 Package           Arch   Version        Repository                                       Size
=================================================================================================
Installing:
 java-1.7.0-oracle x86_64 1.7.0.80-1.0.cf /java-1.7.0-oracle-1.7.0.80-1.0.cf.x86_64         92 M
 java-1.7.0-oracle-plugin
                   x86_64 1.7.0.80-1.0.cf /java-1.7.0-oracle-plugin-1.7.0.80-1.0.cf.x86_64 1.6 M

Transaction Summary
=================================================================================================
Install       2 Packages

Total size: 94 M
Installed size: 94 M
Is this ok [y/N]: y
Downloading Packages:
Running Transaction Check
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : java-1.7.0-oracle-1.7.0.80-1.0.cf.x86_64                                       1/2
  Installing : java-1.7.0-oracle-plugin-1.7.0.80-1.0.cf.x86_64                                2/2

Installed:
  java-1.7.0-oracle.x86_64 0:1.7.0.80-1.0.cf   java-1.7.0-oracle-plugin.x86_64 0:1.7.0.80-1.0.cf

Complete!
[localhost x86_64]$

/!\ For installs on 32-bit systems, use the i586 packages in the ~/rpmbuild/RPMS/i586/ directory instead

<!> The current version of the browser plugin requires an executable stack and will only work if the allow_execstack SELinux boolean is set (Bug #628031). This turns off valuable protection against stack overflow vulnerabilities for the entire system though, so only do this if you really need to install the plugin. It's worth noting though that allow_execstack has been on by default in Fedora releases prior to Fedora 14, and is back on in Fedora 15 onwards.

{i} Java SE 7 Update 6 onwards includes the JavaFX runtime; in order to take full advantage of this functionality, it's necessary to install ffmpeg libraries from a third-party repository such as RPM Fusion in addition to the java-1.7.0-oracle-javafx package. This is outside the scope of this guide. Note that the JavaFX runtime requires a more modern Linux environment than the main JDK/JRE, and is not installable on old distributions such as Red Hat Enterprise Linux 5 due to needing more recent C/C++ libraries.

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 x86_64]$ sudo yum --nogpgcheck localinstall java-1.7.0-oracle*.rpm
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Examining java-1.7.0-oracle-1.7.0.80-1.0.cf.x86_64.rpm: java-1.7.0-oracle-1.7.0.80-1.0.cf.x86_64
Marking java-1.7.0-oracle-1.7.0.72-2.0.c2.0.cf64.rpm to be installed
Examining java-1.7.0-oracle-devel-1.7.0.80-1.0.cf.x86_64.rpm: java-1.7.0-oracle-devel-1.7.0.80-1.0.cf.x86_64
Marking java-1.7.0-oracle-devel-1.7.0.80-1.0.cf.x86_64.rpm to be installed
Examining java-1.7.0-oracle-javafx-1.7.0.80-1.0.cf.x86_64.rpm: java-1.7.0-oracle-javafx-1.7.0.80-1.0.cf.x86_64
Marking java-1.7.0-oracle-javafx-1.7.0.80-1.0.cf.x86_64.rpm to be installed
Examining java-1.7.0-oracle-jdbc-1.7.0.80-1.0.cf.x86_64.rpm: java-1.7.0-oracle-jdbc-1.7.0.80-1.0.cf.x86_64
Marking java-1.7.0-oracle-jdbc-1.7.0.80-1.0.cf.x86_64.rpm to be installed
Examining java-1.7.0-oracle-plugin-1.7.0.80-1.0.cf.x86_64.rpm: java-1.7.0-oracle-plugin-1.7.0.80-1.0.cf.x86_64
Marking java-1.7.0-oracle-plugin-1.7.0.80-1.0.cf.x86_64.rpm to be installed
Examining java-1.7.0-oracle-src-1.7.0.80-1.0.cf.x86_64.rpm: java-1.7.0-oracle-src-1.7.0.80-1.0.cf.x86_64
Marking java-1.7.0-oracle-src-1.7.0.80-1.0.cf.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package java-1.7.0-oracle.x86_64 0:1.7.0.80-1.0.cf will be installed
---> Package java-1.7.0-oracle-devel.x86_64 0:1.7.0.80-1.0.cf will be installed
---> Package java-1.7.0-oracle-javafx.x86_64 0:1.7.0.80-1.0.cf will be installed
---> Package java-1.7.0-oracle-jdbc.x86_64 0:1.7.0.80-1.0.cf will be installed
--> Processing Dependency: /usr/lib64/libodbc.so for package: java-1.7.0-oracle-jdbc-1.7.0.80-1.0.cf.x86_64
--> Processing Dependency: /usr/lib64/libodbcinst.so for package: java-1.7.0-oracle-jdbc-1.7.0.80-1.0.cf.x86_64
---> Package java-1.7.0-oracle-plugin.x86_64 0:1.7.0.80-1.0.cf will be installed
---> Package java-1.7.0-oracle-src.x86_64 0:1.7.0.80-1.0.cf will be installed
--> Running transaction check
---> Package unixODBC.x86_64 0:2.2.14-12.el6_3 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================
 Package    Arch   Version         Repository                                        Size
==========================================================================================
Installing:
 java-1.7.0-oracle
            x86_64 1.7.0.80-1.0.cf /java-1.7.0-oracle-1.7.0.80-1.0.cf.x86_64         93 M
 java-1.7.0-oracle-devel
            x86_64 1.7.0.80-1.0.cf /java-1.7.0-oracle-devel-1.7.0.80-1.0.cf.x86_64   63 M
 java-1.7.0-oracle-javafx
            x86_64 1.7.0.80-1.0.cf /java-1.7.0-oracle-javafx-1.7.0.80-1.0.cf.x86_64  42 M
 java-1.7.0-oracle-jdbc
            x86_64 1.7.0.80-1.0.cf /java-1.7.0-oracle-jdbc-1.7.0.80-1.0.cf.x86_64    78 k
 java-1.7.0-oracle-plugin
            x86_64 1.7.0.80-1.0.cf /java-1.7.0-oracle-plugin-1.7.0.80-1.0.cf.x86_64 1.8 M
 java-1.7.0-oracle-src
            x86_64 1.7.0.80-1.0.cf /java-1.7.0-oracle-src-1.7.0.80-1.0.cf.x86_64     19 M
Installing for dependencies:
 unixODBC   x86_64 2.2.14-12.el6_3 base                                             378 k

Transaction Summary
==========================================================================================
Install       7 Package(s)

Total size: 220 M
Total download size: 378 k
Installed size: 220 M
Is this ok [y/N]: y
Downloading Packages:
unixODBC-2.2.14-12.el6_3.x86_64.rpm                                | 378 kB     00:01
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : java-1.7.0-oracle-1.7.0.80-1.0.cf.x86_64                               1/7
  Installing : unixODBC-2.2.14-12.el6_3.x86_64                                        2/7
  Installing : java-1.7.0-oracle-jdbc-1.7.0.80-1.0.cf.x86_64                          3/7
  Installing : java-1.7.0-oracle-src-1.7.0.80-1.0.cf.x86_64                           4/7
  Installing : java-1.7.0-oracle-devel-1.7.0.80-1.0.cf.x86_64                         5/7
  Installing : java-1.7.0-oracle-javafx-1.7.0.80-1.0.cf.x86_64                        6/7
  Installing : java-1.7.0-oracle-plugin-1.7.0.80-1.0.cf.x86_64                        7/7
  Verifying  : java-1.7.0-oracle-src-1.7.0.80-1.0.cf.x86_64                           1/7
  Verifying  : java-1.7.0-oracle-1.7.0.80-1.0.cf.x86_64                               2/7
  Verifying  : java-1.7.0-oracle-devel-1.7.0.80-1.0.cf.x86_64                         3/7
  Verifying  : unixODBC-2.2.14-12.el6_3.x86_64                                        4/7
  Verifying  : java-1.7.0-oracle-javafx-1.7.0.80-1.0.cf.x86_64                        5/7
  Verifying  : java-1.7.0-oracle-plugin-1.7.0.80-1.0.cf.x86_64                        6/7
  Verifying  : java-1.7.0-oracle-jdbc-1.7.0.80-1.0.cf.x86_64                          7/7

Installed:
  java-1.7.0-oracle.x86_64 0:1.7.0.80-1.0.cf
  java-1.7.0-oracle-devel.x86_64 0:1.7.0.80-1.0.cf
  java-1.7.0-oracle-javafx.x86_64 0:1.7.0.80-1.0.cf
  java-1.7.0-oracle-jdbc.x86_64 0:1.7.0.80-1.0.cf
  java-1.7.0-oracle-plugin.x86_64 0:1.7.0.80-1.0.cf
  java-1.7.0-oracle-src.x86_64 0:1.7.0.80-1.0.cf

Dependency Installed:
  unixODBC.x86_64 0:2.2.14-12.el6_3

Complete!
[localhost x86_64]$

Check Java Version

[localhost x86_64]$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
[localhost x86_64]$

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/java-1.8.0-openjdk-1.8.0.40-25.b25.fc21.x86_64/jre/bin/java
   2           /usr/lib/jvm/jre-1.7.0-oracle.x86_64/bin/java

Enter to keep the current selection[+], or type selection number: 2

[localhost ~]$ java -version
java version "1.7.0_80"
Java(TM) SE Runtime Environment (build 1.7.0_80-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.80-b11, mixed mode)
[localhost ~]$ sudo /usr/sbin/alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
   1           /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.31-3.b13.fc21.x86_64/jre/bin/java
*+ 2           /usr/lib/jvm/jre-1.7.0-oracle.x86_64/bin/java

Enter to keep the current selection[+], or type selection number: 1
[localhost ~]$ java -version
openjdk version "1.8.0_40"
OpenJDK Runtime Environment (build 1.8.0_40-b25)
OpenJDK 64-Bit Server VM (build 25.40-b25, mixed mode)
[localhost ~]$ sudo /usr/sbin/alternatives --auto java
[localhost ~]$ java -version
openjdk version "1.8.0_40"
OpenJDK Runtime Environment (build 1.8.0_40-b25)
OpenJDK 64-Bit Server VM (build 25.40-b25, mixed mode)
[localhost ~]$

A separate alternatives setting is used for the browser plugin:

[localhost ~]$ sudo /usr/sbin/alternatives --config libjavaplugin.so.x86_64

There are 2 programs which provide 'libjavaplugin.so.x86_64'.

  Selection    Command
-----------------------------------------------
   1           /usr/lib64/IcedTeaPlugin.so
*+ 2           /usr/lib/jvm/jre-1.7.0-oracle.x86_64/lib/amd64/libnpjp2.so

Enter to keep the current selection[+], or type selection number: 2

Or, on 32-bit systems:

[localhost ~]$ sudo /usr/sbin/alternatives --config libjavaplugin.so

There are 3 programs which provide 'libjavaplugin.so'.

  Selection    Command
-----------------------------------------------
   1           /usr/lib/jvm/jre-1.6.0-openjdk/lib/i386/IcedTeaPlugin.so
   2           /usr/lib/jvm/jre-1.6.0-sun/lib/i386/libnpjp2.so
*+ 3           /usr/lib/jvm/jre-1.7.0-oracle/lib/i386/libnpjp2.so

Enter to keep the current selection[+], or type selection number: 3

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.7.0_sun_local_policy.x86_64 (or jce_1.7.0_sun_local_policy on 32-bit systems)

  • jre_sun

  • jre_1.7.0

  • javac (if you've installed java-1.7.0-oracle-devel)

  • java_sdk_sun (if you've installed java-1.7.0-oracle-devel)

  • java_sdk_1.7.0 (if you've installed java-1.7.0-oracle-devel)

References


CategoryTip

Recent