Install Sun/Oracle Java JDK/JRE 7u21 on Fedora 18/17, CentOS/RHEL 6.4/5.9

This is guide, howto Install Sun/Oracle Java JDK and JRE 7 update 21 (7u21) on Fedora 18/17/16/15/14/13/12, CentOS 6.4/6.3/6.2/6.1/6/5.9, Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9.

If you’re looking instruction for Sun/Oracle Java JDK/JRE version 6 installation on Fedora 18/17, CentOS/Red Hat (RHEL) 6.4/5.9, please check this guide.

What’s new in Sun/Oracle Java 7

  • VM
    • Compressed 64-bit object pointers
    • Garbage-First GC (G1)
    • JSR 292: VM support for non-Java languages (InvokeDynamic)
  • Lang
    • JSR 294: Language and VM support for modular programming
    • JSR 308: Annotations on Java types
    • JSR TBD: Small language enhancements (Project Coin)
    • JSR TBD: Project Lambda
  • Core
    • Modularization (Project Jigsaw)
    • Upgrade class-loader architecture
    • Method to close a URLClassLoader
    • Unicode 5.1
    • Concurrency and collections updates (jsr166y)
    • JSR 203: More new I/O APIs for the Java platform (NIO.2)
    • SCTP (Stream Control Transmission Protocol)
    • SDP (Sockets Direct Protocol)
    • Elliptic-curve cryptography (ECC)
  • Client
    • XRender pipeline for Java 2D
    • Nimbus look-and-feel for Swing
    • Swing JLayer component
  • Web
    • Update the XML stack

Read full info from here.

Install Sun/Oracle Java JDK/JRE 7u21 on Fedora 18/17/16/15/14/13/12, CentOS 6.4/6.3/6.2/6.1/6/5.9, Red Hat (RHEL) 6.4/6.3/6.2/6.1/6/5.9

1. Download Sun/Oracle Java JDK/JRE 7u21 32-bit/64-bit RPM packages

Download Sun/Oracle Java 7u21 from here http://www.oracle.com/technetwork/java/javase/downloads/index.html. Select rpm package (jdk-7u21-linux-i586.rpm, jdk-7u21-linux-x64.rpm, jre-7u21-linux-i586.rpm or jre-7u21-linux-x64.rpm).

2. Change to root user.

sudo -i
## OR ##
su -

3. Install Java JDK or JRE package

## JDK 32-bit ##
rpm -Uvh /path/to/binary/jdk-7u21-linux-i586.rpm
 
## JDK 64-bit ##
rpm -Uvh /path/to/binary/jdk-7u21-linux-x64.rpm
 
## JRE 32-bit ##
rpm -Uvh /path/to/binary/jre-7u21-linux-i586.rpm
 
## JRE 64-bit ##
rpm -Uvh /path/to/binary/jre-7u21-linux-x64.rpm

4a. Install Sun/Oracle JDK java, javaws, libjavaplugin.so (for Firefox/Mozilla) and javac with alternatives –install command

Use Java JDK latest version (/usr/java/latest)

## java ##
alternatives --install /usr/bin/java java /usr/java/latest/jre/bin/java 20000
## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 20000
 
## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/latest/jre/lib/i386/libnpjp2.so 20000
 
## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/latest/jre/lib/amd64/libnpjp2.so 20000
 
## Install javac only if you installed JDK (Java Development Kit) package ##
alternatives --install /usr/bin/javac javac /usr/java/latest/bin/javac 20000
alternatives --install /usr/bin/jar jar /usr/java/latest/bin/jar 20000

Use Java JDK absolute version (/usr/java/jdk1.7.0_21)

## java ##
alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_21/jre/bin/java 20000
## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.7.0_21/jre/bin/javaws 20000
 
## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jdk1.7.0_21/jre/lib/i386/libnpjp2.so 20000
 
## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/jdk1.7.0_21/jre/lib/amd64/libnpjp2.so 20000
 
## Install javac only if you installed JDK (Java Development Kit) package ##
alternatives --install /usr/bin/javac javac /usr/java/jdk1.7.0_21/bin/javac 20000
alternatives --install /usr/bin/jar jar /usr/java/jdk1.7.0_21/bin/jar 20000

4b. Install Sun/Oracle JRE java, javaws and libjavaplugin.so (for Firefox/Mozilla) with alternatives –install command

Use Java JRE latest version (/usr/java/latest)

## java ##
alternatives --install /usr/bin/java java /usr/java/latest/bin/java 20000
 
## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/latest/bin/javaws 20000
 
## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/latest/lib/i386/libnpjp2.so 20000
 
## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/latest/lib/amd64/libnpjp2.so 20000

Use Java JRE absolute version (/usr/java/jre1.7.0_21)

## java ##
alternatives --install /usr/bin/java java /usr/java/jre1.7.0_21/bin/java 20000
 
## javaws ##
alternatives --install /usr/bin/javaws javaws /usr/java/jre1.7.0_21/bin/javaws 20000
 
## Java Browser (Mozilla) Plugin 32-bit ##
alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jre1.7.0_21/lib/i386/libnpjp2.so 20000
 
## Java Browser (Mozilla) Plugin 64-bit ##
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/jre1.7.0_21/lib/amd64/libnpjp2.so 20000

5. Check current java, javac, javaws and libjavaplugin.so versions

java -version
java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b04)
Java HotSpot(TM) 64-Bit Server VM (build 22.1-b02, mixed mode)
 
javaws
Java(TM) Web Start 10.0.0.4-fcs
[...]
 
javac -version
javac 1.7.0_21

Note: Check libjavaplugin.so with restarting Mozilla Firefox and writing about:plugins on address bar.

Java 7 console output on Fedora 18:

6. Swap between OpenJDK and Sun/Oracle Java JDK/JRE 6 and 7 versions

java

alternatives --config java
 
There are 5 programs which provide 'java'.
 
  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/jre/bin/java
   2           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
 + 3           /usr/java/jdk1.6.0_26/jre/bin/java
   4           /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
   5           /usr/java/jdk1.7.0_21/jre/bin/java
 
Enter to keep the current selection[+], or type selection number: 5

Note: java with [+] is currently on use

javaws

alternatives --config javaws
 
There are 3 programs which provide 'javaws'.
 
  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/jre/bin/javaws
 + 2           /usr/java/jdk1.6.0_26/jre/bin/javaws
   3           /usr/java/jdk1.7.0_21/jre/bin/javaws
 
Enter to keep the current selection[+], or type selection number: 3

Note: java with [+] is currently on use

libjavaplugin.so (32-bit)

alternatives --config libjavaplugin.so
 
There are 3 programs which provide 'libjavaplugin.so'.
 
  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/jre/lib/i386/libnpjp2.so
 + 2           /usr/java/jdk1.6.0_26/jre/lib/i386/libnpjp2.so
   3           /usr/java/jdk1.7.0_21/jre/lib/i386/libnpjp2.so
 
Enter to keep the current selection[+], or type selection number: 3

libjavaplugin.so.x86_64 (64-bit)

alternatives --config libjavaplugin.so.x86_64
 
There are 3 programs which provide 'libjavaplugin.so.x86_64'.
 
  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/jre/lib/amd64/libnpjp2.so
 + 2           /usr/java/jdk1.6.0_26/jre/lib/amd64/libnpjp2.so
   3           /usr/java/jdk1.7.0_21/jre/lib/amd64/libnpjp2.so
 
Enter to keep the current selection[+], or type selection number: 3

javac

alternatives --config javac
 
There are 3 programs which provide 'javac'.
 
  Selection    Command
-----------------------------------------------
*  1           /usr/java/jdk1.6.0_24/bin/javac
 + 2           /usr/java/jdk1.6.0_26/bin/javac
   3           /usr/java/jdk1.7.0_21/bin/javac
 
Enter to keep the current selection[+], or type selection number: 3

Note: java with [+] is currently on use

Post-Installation Setup

Add JAVA_HOME environment variable to /etc/profile file or $HOME/.bash_profile file

Java JDK and JRE latest version (/usr/java/latest)

## export JAVA_HOME JDK/JRE ##
export JAVA_HOME="/usr/java/latest"

Java JDK and JRE absolute version (/usr/java/jdk1.7.0_21)

## export JAVA_HOME JDK ##
export JAVA_HOME="/usr/java/jdk1.7.0_21"
 
## export JAVA_HOME JRE ##
export JAVA_HOME="/usr/java/jre1.7.0_21"
Follow If Not True Then False Updates!

178 Comments

  1. Awesome thread and I very much needed your help. I followed your instructions and when I ran the code java -version it gave me an error telling me that the command does not exist. I troubleshooted and the issue I found is that the JRE folder is missing under usr/java/latest folder. And no matter how many times I run these commands:

    alternatives –install /usr/bin/java java /usr/java/latest/jre/bin/java 20000
    alternatives –install /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws 20000

    It still will not create the folders thus I believe the cause of the Java command not found issue. Could you please help? I would appreciate any reply:

    • Hi mervs,

      Actually alternatives –install commands doesn’t create folders, it just create symbolic links. Could you post output of following commands:

      rpm -qa jre\* jdk\*
       
      ls -la /usr/java
       
      ls -la /usr/java/jre*
       
      ls -la /usr/java/jdk*
  2. Amazing post guys! Very useful !

  3. Thanks very much for the post!

  4. Hi, thanks for helpful lessons but here I got an error: http://i45.tinypic.com/6ql9g5.png

    So what I can do and install this java package?

    Best regards,
    George!

    • Hi George,

      You can ignore those .pack file errors, all jar packages are unpacked successfully (without errors). .pack files are used by Java Web Start clients to retrieve and unpack JAR files for Java programs. So these errors doesn’t affect the JRE / JDK functionality when you install it using RPM package.

      But only rpm installation is not enough, you have to setup your new Java version also, so first install rpm, ignore .pack errors and then follow this guide.

      • I have the exactly same problem. How can I ignore those .pack errors?
        when I try to do it again it says ” package jdk-2000:1.7.0_11-fcs.x86_64 is already installed” is the jdk completely installed?

        Thanks

        • Hi Richard,

          Yes you have JDK package installed just normally, when you get “package jdk-2000:1.7.0_11-fcs.x86_64 is already installed”, and it’s completely installed even if you get those .pack file errors and then next steo is just setup java, javac, etc.

        • Hi, Richard, just continue with the installation. This is not a real problem for you :)

          JR, thank you, mate!

          • Well thanks a lot JR and George , it really works 100% now.

            • Excellent! :)

  5. Hi,
    I slightly modified your alternatives approach as follows:

    alternatives –verbose –install /usr/bin/java java /usr/java/latest/jre/b$
    –slave /usr/bin/JAVA_HOME JAVA_HOME /usr/java/latest \
    –slave /usr/bin/javaws javaws /usr/java/latest/jre/bin/javaws \
    –slave /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/l$
    –slave /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /u$
    –slave /usr/bin/javac javac /usr/java/latest/bin/javac \
    –slave /usr/bin/jar jar /usr/java/latest/bin/jar

    Later on, I do
    export JAVA_HOME=/etc/alternatives/JAVA_HOME

    In this way, I limit inconsistency risks further.

    Thanks for your great blog.

    • Hi Casier,

      This is nice alternatives approach, thanks for sharing!

  6. Straightforward, Brilliant!

    Thanks

    • Just one point to review…

      Now I noticed that Firefox plugin is not getting updated. Just like the screenshot you have posted. Installed revision 11 but the “Check libjavaplugin.so with restarting Mozilla…” is showing revision 10.

      In my environment I have similiar behavior: installed revision 11 but the Firefox about:plugins is showing previous version 05.

      Nevertheless, when running firefox as root the plugin is shown updated.

      Please help!
      TIA

      • Hi Renato,

        Try following:

        ## 32-bit ##
        alternatives --config libjavaplugin.so
         
        ## 64-bit ##
        alternatives --config libjavaplugin.so.x86_64

        And then select right version and restart Firefox (or even log out and back in).

        • Wow. You’ve got the point!

          With the recent revision 13 made available, I amended the procedure according to .13 and it is working perfectly.

          Thanks so much for your great help JR.

          • Excellent! :)

            I updated this guide to Java 7u13 too. :) Btw. if you want stay up to date little bit easier then you can use “latest method” when you run alternatives –install, like following:

            ## Example JRE 64-bit ##
            alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/latest/lib/amd64/libnpjp2.so 20000

            You can check where latest point on file system:

            ls -la /usr/bin/java
            • Should that be “ls -la /usr/bin/java” ? (Running CentOS 6.4 64-bit)

              • Hi Peter,

                Yes it should :) I updated this comment, thanks!

  7. Nice one..

  8. After struggling to do this for so long and confusing instructions for CENTOS 4/5, the instructions above are awesome. Thank you!

  9. Question for you: I’ve been teaching myself java programming through the free online class that Stanford offers, but the sample lessons they provide require a 6 runtime enviroment. I found an rpm file of openjdk 6 but when I try to install it, it stops my since I already have openjdk7. How can I install these side by side?

    • Hi Topher,

      You could try following command to install OpenJDK 6, when you have OpenJDK 7 installed:

      rpm --nodeps -ihv /path/to/java-1.6.0-openjdk-1.6.*.rpm
      • Thanks! Worked like a charm!

        • Excellent! :)

  10. Hi, at the first step, when i try to install i get this message :

    [root@fedoracore Downloads]# rpm -Uvh jdk-7u15-linux-x64.rpm
    Preparing… ################################# [100%]
    Updating / installing…
    1:jdk-2000:1.7.0_15-fcs ################################# [100%]
    Unpacking JAR files…
    rt.jar…
    Error: Could not open input file: /usr/java/jdk1.7.0_15/jre/lib/rt.pack
    jsse.jar…
    Error: Could not open input file: /usr/java/jdk1.7.0_15/jre/lib/jsse.pack
    charsets.jar…
    Error: Could not open input file: /usr/java/jdk1.7.0_15/jre/lib/charsets.pack
    tools.jar…
    Error: Could not open input file: /usr/java/jdk1.7.0_15/lib/tools.pack
    localedata.jar…
    Error: Could not open input file: /usr/java/jdk1.7.0_15/jre/lib/ext/localedata.pack

    What is the cause of this, i both tried to install jde and jdk but result is the same. Thank you very much for your guides.

  11. I do not know what caused my problem but i removed all java versions with this command :

    yum remove *java*

    After that i rebooted my fedora 18 and followed the guide again with the new version of jre and jdk 1.7u15

    I hope this helps.

    • Hi nightshift,

      You can ignore those .pack file errors, all jar packages are unpacked successfully (without errors). .pack files are used by Java Web Start clients to retrieve and unpack JAR files for Java programs. So these errors doesn’t affect the JRE / JDK functionality when you install it using RPM package.

  12. This tutorial rock!

  13. Hi JR,

    Thanks a lot you save my night!

  14. Hi, I wish you could give a hand on this, my friend.
    After download java-re as you can see below, all I got is this output:

    cd Downloads/
    [root@localhost Downloads]# ls
    jre-7u15-linux-i586.rpm
    [root@localhost Downloads]# rpm -Uvh /path/to/binary/jre-7u15-linux-i586.rpm
    error: open of /path/to/binary/jre-7u15-linux-i586.rpm failed: No such file or directory
    [root@localhost Downloads]#

    I don’t what I’m overlooking, I’d appreciate any clue.
    Thanks.
    Txe

    • Hi txe,

      /path/to/binary means path to jre-7u15-linux-*.rpm file, so if you are downloads path, then your path to binary is “empty” or ./

      Same command on your case:

      rpm -Uvh jre-7u15-linux-i586.rpm
      • Hi JR,
        Thanks for your reply.
        Yes you are absolutely right, I should have been cloud (it was a hard long day.. sorry.) However I’m really lost now. The output I got when I type (being root) $rpm -Uvh jre-7u15-linux-i586.rpm is that the package is already installed ๏๏.

        So what I did was to carry on whit the rest of your guide. In my case:
        ## java ##
        alternatives --install /usr/bin/java java /usr/java/jre-1.7.0_15-fcs.i586/bin/java 20000

        ## javaws ##
        alternatives --install /usr/bin/javaws javaws /usr/java/jre-1.7.0_15-fcs.i586/bin/javaws 20000

        ## Java Browser (Mozilla) Plugin 32-bit ##
        alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jre-1.7.0_15-fcs.i586/lib/i386/libnpjp2.so 20000 Whit no reply from cli in any of these cases so I though it was going OK. However when I type java –version this is the output I got:

        [txe@localhost Downloads]$ java --version
        bash: java: command not found...
        [txe@localhost Downloads]$ which java
        /usr/bin/which: no java in (/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/home/txe/.local/bin:/home/txe/bin)
        [txe@localhost Downloads]$

        Any help, please?, please..
        Txe.

        • Probably I typed wrong again I said, I tried also this lines with, and still unsuccessful.

          alternatives –install /usr/bin/java java /usr/java/jre-1.7.0_15/bin/java 20000
          alternatives –install /usr/bin/javaws javaws /usr/java/jre-1.7.0_15/bin/javaws 20000
          alternatives –install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/jre-1.7.0_15/lib/i386/libnpjp2.so 20000

          Txe

          • Hi txe,

            Could you post output of following command:

            ls -la /usr/java
            • Hi JR.
              Thanks for your reply
              This the output I got:

              [txe@localhost ~]$ ls -la /usr/java
              total 12
              drwxr-xr-x. 3 root root 4096 Feb 27 23:52 .
              drwxr-xr-x. 13 root root 4096 Feb 27 23:52 ..
              lrwxrwxrwx. 1 root root 16 Feb 27 23:52 default -> /usr/java/latest
              drwxr-xr-x. 6 root root 4096 Feb 27 23:52 jre1.7.0_15
              lrwxrwxrwx. 1 root root 21 Feb 27 23:52 latest -> /usr/java/jre1.7.0_15
              [txe@localhost ~]$

              • Thanks, it looks good, could you then post output of following commands:

                alternatives --display java
                 
                alternatives --display javaws
                 
                alternatives --display libjavaplugin.so

                And then also output of following command:

                /usr/java/jre-1.7.0_15/bin/java --version
                • Hi JR,
                  Here it’s the output I got for each line, my friend:
                  Thanks.

                  [txe@localhost ~]$ alternatives --display java
                  java - status is auto.
                  link currently points to /usr/java/latest/jre/bin/java
                  /usr/java/latest/jre/bin/java - priority 20000
                  slave keytool: (null)
                  slave orbd: (null)
                  slave pack200: (null)
                  slave rmid: (null)
                  slave rmiregistry: (null)
                  slave servertool: (null)
                  slave tnameserv: (null)
                  slave unpack200: (null)
                  slave jre_exports: (null)
                  slave jre: (null)
                  slave java.1.gz: (null)
                  slave keytool.1.gz: (null)
                  slave orbd.1.gz: (null)
                  slave pack200.1.gz: (null)
                  slave rmid.1.gz: (null)
                  slave rmiregistry.1.gz: (null)
                  slave servertool.1.gz: (null)
                  slave tnameserv.1.gz: (null)
                  slave unpack200.1.gz: (null)
                  /usr/java/jre-1.7.0_15-fcs.i586/bin/java - priority 20000
                  slave keytool: (null)
                  slave orbd: (null)
                  slave pack200: (null)
                  slave rmid: (null)
                  slave rmiregistry: (null)
                  slave servertool: (null)
                  slave tnameserv: (null)
                  slave unpack200: (null)
                  slave jre_exports: (null)
                  slave jre: (null)
                  slave java.1.gz: (null)
                  slave keytool.1.gz: (null)
                  slave orbd.1.gz: (null)
                  slave pack200.1.gz: (null)
                  slave rmid.1.gz: (null)
                  slave rmiregistry.1.gz: (null)
                  slave servertool.1.gz: (null)
                  slave tnameserv.1.gz: (null)
                  slave unpack200.1.gz: (null)
                  /usr/java/jre-1.7.0_15/bin/java - priority 20000
                  slave keytool: (null)
                  slave orbd: (null)
                  slave pack200: (null)
                  slave rmid: (null)
                  slave rmiregistry: (null)
                  slave servertool: (null)
                  slave tnameserv: (null)
                  slave unpack200: (null)
                  slave jre_exports: (null)
                  slave jre: (null)
                  slave java.1.gz: (null)
                  slave keytool.1.gz: (null)
                  slave orbd.1.gz: (null)
                  slave pack200.1.gz: (null)
                  slave rmid.1.gz: (null)
                  slave rmiregistry.1.gz: (null)
                  slave servertool.1.gz: (null)
                  slave tnameserv.1.gz: (null)
                  slave unpack200.1.gz: (null)
                  Current `best' version is /usr/java/latest/jre/bin/java.
                  [txe@localhost ~]$
                  ------------------------
                  [txe@localhost ~]$ alternatives --display javaws
                  javaws - status is auto.
                  link currently points to /usr/java/jre-1.7.0_15-fcs.i586/bin/javaws
                  /usr/java/jre-1.7.0_15-fcs.i586/bin/javaws - priority 20000
                  /usr/java/jre-1.7.0_15/bin/javaws - priority 20000
                  Current `best' version is /usr/java/jre-1.7.0_15-fcs.i586/bin/javaws.
                  [txe@localhost ~]$
                  ---------------------
                  [txe@localhost ~]$ alternatives --display libjavaplugin.so
                  libjavaplugin.so - status is auto.
                  link currently points to /usr/java/latest/jre/lib/i386/libnpjp2.so
                  /usr/java/latest/jre/lib/i386/libnpjp2.so - priority 20000
                  /usr/java/jdk1.7.0_15/jre/lib/i386/libnpjp2.so - priority 20000
                  /usr/java/jre-1.7.0_15-fcs.i586/lib/i386/libnpjp2.so - priority 20000
                  /usr/java/jre-1.7.0_15/lib/i386/libnpjp2.so - priority 20000
                  Current `best' version is /usr/java/latest/jre/lib/i386/libnpjp2.so.
                  [txe@localhost ~]$
                  ----------------------
                  [txe@localhost ~]$ /usr/java/jre-1.7.0_15/bin/java --version
                  bash: /usr/java/jre-1.7.0_15/bin/java: No such file or directory
                  [txe@localhost ~]$

                  • Sorry, I wrote actually wrong path, could you also post output of following commands:

                    /usr/java/jre1.7.0_15/bin/java --version
                     
                    /usr/java/latest/bin/java --version
                    • Hi JR,
                      Sorry, I should have replied here for keeping the thread, isn’t?. But once done I could not reverse the posting process. So re-post it, here again. Sorry to the inconvenience.

                      [txe@localhost ~]$ /usr/java/jre1.7.0_15/bin/java --version
                      Unrecognized option: --version
                      Error: Could not create the Java Virtual Machine.
                      Error: A fatal exception has occurred. Program will exit.
                      [txe@localhost ~]$


                      [txe@localhost ~]$ /usr/java/latest/bin/java --version
                      Unrecognized option: --version
                      Error: Could not create the Java Virtual Machine.
                      Error: A fatal exception has occurred. Program will exit.
                      [txe@localhost ~]$

  15. You deserve to go to heaven for taking the time and effort to write this article for people you don’t even know. Your work is highly appreciated!

  16. thanks for great support

  17. Hi JR,
    Thanks again. Here both outputs:

    [txe@localhost ~]$ /usr/java/jre1.7.0_15/bin/java --version
    Unrecognized option: --version
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.
    [txe@localhost ~]$

    ------------------------

    [txe@localhost ~]$ /usr/java/latest/bin/java --version
    Unrecognized option: --version
    Error: Could not create the Java Virtual Machine.
    Error: A fatal exception has occurred. Program will exit.
    [txe@localhost ~]$

    • Let’s continue here, this discussion.

      First run following commands (remove your current linking):

      alternatives --remove java /usr/java/latest/jre/bin/java
       
      alternatives --remove java /usr/java/jre-1.7.0_15-fcs.i586/bin/java
       
      alternatives --remove java /usr/java/jre-1.7.0_15/bin/java
       
      alternatives --remove javaws /usr/java/jre-1.7.0_15-fcs.i586/bin/javaws
       
      alternatives --remove javaws /usr/java/jre-1.7.0_15/bin/javaws
       
      alternatives --remove libjavaplugin.so /usr/java/latest/jre/lib/i386/libnpjp2.so
       
      alternatives --remove libjavaplugin.so /usr/java/jdk1.7.0_15/jre/lib/i386/libnpjp2.so
       
      alternatives --remove libjavaplugin.so /usr/java/jre-1.7.0_15-fcs.i586/lib/i386/libnpjp2.so
       
      alternatives --remove libjavaplugin.so /usr/java/jre-1.7.0_15/lib/i386/libnpjp2.so

      Then install java, javaws and java plugin again:

      ## java ##
      alternatives --install /usr/bin/java java /usr/java/latest/bin/java 20000
       
      ## javaws ##
      alternatives --install /usr/bin/javaws javaws /usr/java/latest/bin/javaws 20000
       
      ## Java Browser (Mozilla) Plugin 32-bit ##
      alternatives --install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/latest/lib/i386/libnpjp2.so 20000

      Then try:

      java -version
      • Hi JR,
        Thanks for your reply. This is the output I got now:

        [root@localhost txe]# java -version
        java version "1.7.0_15"
        Java(TM) SE Runtime Environment (build 1.7.0_15-b03)
        Java HotSpot(TM) Server VM (build 23.7-b01, mixed mode)
        [root@localhost txe]#

        Then I checked out for plugins (about:plugins) on firefox and I can see them installed, though with a warning indication about using java on ff. (I hope it’s right thing using it..). Is there anything else I should do?
        I really appreciate your help.
        Txe.

        • Hi txe,

          You got Java installed as it should be, but one thing to do now, is update installed Java JRE 7u15 to latest update 17, which fix Java browser plugin bug.

          Now when you use latest method, you can just download new package and install it using following command:

          rpm -Uvh /path/to/binary/jre-7u17-linux-i586.rpm

          Then you can check that it’s properly updated using following command:

          java -version

          And you can check browser plugin version on about:plugins page.

          • Ah!. Ok. but don’t I have to uninstall the previous one version or something like that?
            Thanks!
            Txe.

            • Hi txe,

              You can just update previous version with rpm -Uvh jre-7u17-linux-i586.rpm command, so you don’t have to uninstall it first.

  18. Hi All,

    I found that on Fedora 18 the shared library libX11 is missing and without it, javaws won’t run. You can het it here: http://pkgs.org/fedora-18/fedora-i386/libX11-1.5.0-3.fc18.i686.rpm/download/

    T.

    • Hi Tiago and thanks!

      You can also install it using yum:

      yum install libX11
  19. Thanks a lot for this very useful instructions!

    Best regards.

    Aníbal

  20. I just tried to install JDK 7-17 on Fedora 18 and got the following error on Step 3. Your assistance would be appreciated:

    [root@localhost ~]# rpm -Uvh /var/tmp/jdk-7u17-linux-x64.rpm
    Preparing… ################################# [100%]
    Updating / installing…
    1:jdk-2000:1.7.0_17-fcs ################################# [100%]
    Unpacking JAR files…
    rt.jar…
    Error: Could not open input file: /usr/java/jdk1.7.0_17/jre/lib/rt.pack
    jsse.jar…
    Error: Could not open input file: /usr/java/jdk1.7.0_17/jre/lib/jsse.pack
    charsets.jar…
    Error: Could not open input file: /usr/java/jdk1.7.0_17/jre/lib/charsets.pack
    tools.jar…
    Error: Could not open input file: /usr/java/jdk1.7.0_17/lib/tools.pack
    localedata.jar…
    Error: Could not open input file: /usr/java/jdk1.7.0_17/jre/lib/ext/localedata.pack

    • Hi getcar,

      You can ignore those .pack file errors, all jar packages are unpacked successfully (without errors). .pack files are used by Java Web Start clients to retrieve and unpack JAR files for Java programs. So these errors doesn’t affect the JRE / JDK functionality when you install it using RPM package.

  21. I want to say first I am running Centos 6.4 in a virtuabox. I don’t think that should be an issue,

    I removed open java yum remove java
    then I downloaded the latest oracle java
    I installed rpm -ivh jdk-7u17-linux-x64.rpm
    then I alternatives –install /usr/bin/java java /usr/java/latest/jre/bin/java 20000
    then rnatives –install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.s
    then I linked the plugin to ~/.mozilla/plugins

    Now whenever I hit a java site firefox crashes. It goes down fast too. I don’t even know what to check

    If I look at about:plugins I see the java plugins
    java -version
    java version “1.7.0_17″
    Java(TM) SE Runtime Environment (build 1.7.0_17-b02)
    Java Hotspot(TM) 64-Bit Server VM (Build 23.7-b01, mixed mode)

    any ideas on why firefox is crashing now would be appreciated.

    Thanks again,
    Mike

    • Hi Mike,

      It’s not needed to link ~/.mozilla/plugins, if you run following command (Java JRE installation):

      alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/latest/jre/lib/amd64/libnpjp2.so 20000

      So remove link from ~/.mozilla/plugins and check output of following command:

      ls -la /usr/lib64/mozilla/plugins/libjavaplugin.so
      • @pmkehdvs1001:~/.mozilla/plugins$ ls -la /usr/lib64/mozilla/plugins/libjavaplugin.so
        lrwxrwxrwx. 1 root root 41 Mar 16 22:45 /usr/lib64/mozilla/plugins/libjavaplugin.so -> /etc/alternatives/libjavaplugin.so.x86_64

        Ok done, but firefox still crashes on java pages. If I open firefox and type in javatest in the search bar it hangs for a second then disappears. If I type in cars it will work find and go to wesites with cars in them.

        • Hi Mike,

          Could you post also output of following commands:

          ls -la ~/.mozilla/plugins
           
          alternatives --display libjavaplugin.so.x86_64
  22. Hi JR, Well after hours of playing with it, I remembered that I was building this in a virtualbox. I decided to just start over, and what ever I did wrong or whatever went wrong went right with the second VM. Thank you for your help. I am all good now.

    Thanks again,
    Mike

    • Hi Mike,

      You are welcome! Nice to hear that you got it working!

  23. Thanks very much for the post!

  24. Hi,
    Thanks for the nice guide. I tried to follow your instructions but I run across problems. I’ll be thankful if you can help me out.

    When I run
    $ rpm -Uvh ../jdk-7u21-linux-i586.rpm
    the output was:
    Preparing… ########################################### [100%]
    1:jdk ########################################### [100%]
    error: unpacking of archive failed on file /usr/java/jdk1.7.0_21/db/lib/derby.jar;517bea0a: cpio: Digest mismatch

    I tried to ignore it, but when I run
    alternatives –install /usr/lib/mozilla/plugins/libjavaplugin.so libjavaplugin.so /usr/java/latest/lib/i386/libnpjp2.so 20000
    the output was:
    failed to read link /usr/lib/mozilla/plugins/libjavaplugin.so: No such file or directory

    What is the problem here?
    Thanks,

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackbacks/Pingbacks

  1. Install Sun/Oracle Java JDK/JRE 7 (b108) on Fedora 13/CentOS 5.5 … | java - [...] więcej: Install Sun/Oracle Java JDK/JRE 7 (b108) on Fedora 13/CentOS 5.5 … fedora, jre, main, main-guide, rhel, ...
  2. Install Sun/Oracle Java JDK/JRE 6u26 on Fedora 15, CentOS/RHEL 5.6/6 - [...] Install Sun/Oracle Java JDK/JRE 6u26 on Fedora 15, CentOS/RHEL 5.6/6By JR – Published: July 29, 2010 – Last Updated: ...
  3. Android SDK r12 and Eclipse ADT on Fedora 15/14, CentOS/Red Hat (RHEL) 6 - [...] 1.1 Install Sun/Oracle Java 7 JDK/JRE [...]
  4. Create Full Screen Graphic Displayer - Page 2 - [...] used to barrel ahead willy nilly People say I'm not doing my work I'm sorry but I found this ...
  5. NetBeans 7.0.1 / 7.1 RC1 on Fedora 16/15, CentOS/RHEL 6/5.7 - [...] Sun’s Java, because I think NetBeans works faster with Sun’s Java. Here is the guide, howto install Sun/Oracle Java ...
  6. Installing Java on CentOS 6 and configuring it to use for PHPStrom | Simple Coder - [...] http://www.if-not-true-then-false.com/2010/install-sun-oracle-java-jdk-jre-7-on-fedora-centos-red-ha... [...]
  7. java working but not in firefox - [...] again. I found this very useful when I set up my java, complete with an alternatives chooser: http://www.if-not-true-then-false.co...-red-hat-rhel/ -- ...
  8. How do I install Java on CentOS 6.2? - [...] you want to install JRE on CentOS, follow the steps in this link. I have used this in the ...