Oracle Linux uses RPM (Red Hat Package Manager). If you want to install latest Java platform, you can download Java RPM packages from:

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

Oracle releases Java RPM wrapped in a self-extracting binary file. So instead of using rpm tool, you just change the mode of file, and make it executable and then run it:

Is it done? Let’s check it:

As you see, although we installed the latest Java, we still use the old one. Because of the incompatibilities between Java versions, when you install/update Java, it does not overwrite the previous versions. Instead, all installed Java versions are available to use.

At this point, “alternatives” system takes into action. The alternatives system is a reimplementation of the Debian alternatives system. It maintains symbolic links determining default commands.

Our java is installed under /usr/java/jdk1.6.0_26 (so the path of java binary is /usr/java/jdk1.6.0_26/bin/java). I’ll add this as the default for Java:

Here are the arguments:

–install tells that we’ll add a new alternative
/usr/bin/java is the default path for Java
java is the name of the software
/usr/java/jdk1.6.0_26/bin/java is the path of latest java we installed
16026 is the priority, I recommend you to give the exact version number so when you install a newer version and enter its version as priority, it’ll be selected as the default one (as long as mode is auto).

Let’s the alternatives of Java:

Let’s check the version of java:

You can also change the alternative of Java manually:

Type the number of the alernative you want to use and hit enter key.

29 Responses to “How to Install/Update Java (JDK) on Oracle Linux”

  1. Patricia says:

    Thanx from Spain!!!
    Your post has saved me.

  2. That worked a treat, thank you.

  3. Hi,
    I am running Oracle 11g R2.0.3 on a RedHat 5.8 server. The system java /usr/bin/java is the latest RedHat release of 1.6.
    There is another version of java located in $ORACLE_HOME/jdk/bin which is version 1.5.0_30. How do I update this to the latest?
    Thank you,
    Kerry

    • Gokhan Atil says:

      Hi Kerry, as I see it’s the JDK which is used only by Oracle Database management applications. I don’t see any reason to update it, and I recommend you to not to update it.

  4. You’re a life saver, thanks a lot 🙂

  5. ibtissam says:

    Hi ! I try to download JDK using this command :
    wget http://edelivery.oracle.com/otn-pub/…linux-i586.rpm

    But i get this answer :

    –2013-03-14 15:50:30– http://edelivery.oracle.com/otn-pub/…linux-i586.rpm
    Connecting to 138.21.89.192:3128… connected.
    Proxy request sent, awaiting response… 302 Found
    Location: https://edelivery.oracle.com/otn-pub…linux-i586.rpm [following]
    –2013-03-14 15:50:30– https://edelivery.oracle.com/otn-pub…linux-i586.rpm
    Resolving edelivery.oracle.com… failed: Name or service not known.
    wget: unable to resolve host address `edelivery.oracle.com’

    wget http://www.google.for work .

    Can You help me please?

    • Gokhan Atil says:

      It looks like a DNS problem. You may try to download it on your PC and then transfer the RPM file to the server.

    • ibtissam says:

      it was a problem of certificate on the oracle website ( you have to accept the conditions of the certificate before starting the download ). THank you for your answer, i sent my file using FTP .

  6. awreneau says:

    Great doc, helped me clear a hurdle. Shared it w/ my team. Many thanks.

  7. üstadım ben nokia asha için uygulama yazmak istiyorum fakat asha sdk sını yüklememe rağmen jdk 7 update 21 ve 17 yi yüklememi istedi. ardından bunlarıda yükledim fakat hala hata devam ediyor. rica etsem nedenini açıklayabilir misiniz?
    (ingilizcem pek yok ).

  8. Hi,

    I am someone who only knows the ABC’s of the modern computer. I am attempting to delete Java development kit 6 update 15 and every time I do this a box pops up asking me if I would like to install not uninstall and I of course decline being from an unkown source. I simply would just like to delete it. My computer is overheating and I am about to download photoshop on this computer so I am trying to get rid of programs I do not need. If you think you can really help me with this I would be as forward to give my phone number if you are interested in helping. I am about to embark on a few business ventures and need a quality computer to run from.

    Erin Fitzgerald

    California, USA

  9. David Scholler says:

    Gokhan,

    Your comment “Hi Kerry, as I see it’s the JDK which is used only by Oracle Database management applications. I don’t see any reason to update it, and I recommend you to not to update it.” The only problem with this is security scans are flaging this as not being updated, so we need to update this. I was wondering a way to update this java being oracle isn’t using the system Java that is 1.7.0_25?

    Thanks

    • Gokhan Atil says:

      David, I see what you mean but if you update this Java, oracle tools (using that java) may stop working.

  10. hi am using Linux 4 Update 8

    and i have installed jdk 1.7 on my previous version 1.4 but when i type

    #java -version

    showing

    [root@gdqas java]# java -version
    Error: dl failure on line 863
    Error: failed /usr/java/jdk1.7.0_51/jre/lib/i386/server/libjvm.so, because /lib/tls/libc.so.6: version `GLIBC_2.4′ not found (required by /usr/java/jdk1.7.0_51/jre/lib/i386/server/libjvm.so)

    so i want to uninstall 1.7 and go for 1.6. how to uninstall 1.7 please guide me

    Thanks

  11. Thanks Gokhan,

    Not so complicated if you know it, but still very handy and useful to know!

  12. Gangireddy says:

    Here the 1.6.0_26 related slaves are seems to be null , how we can we override these values to java 1.4.2 values ?

    /usr/sbin/alternativesdisplay java

    javastatus isauto.
    linkcurrently points to/usr/java/jdk1.6.0_26/bin/java
    /usr/lib/jvm/jre1.4.2gcj/bin/javapriority1420
    slave keytool:/usr/lib/jvm/jre1.4.2gcj/bin/keytool
    slave rmiregistry:/usr/lib/jvm/jre1.4.2gcj/bin/rmiregistry
    slave jre_exports:/usr/lib/jvmexports/jre1.4.2gcj
    slave jre:/usr/lib/jvm/jre1.4.2gcj
    /usr/java/jdk1.6.0_26/bin/javapriority16026
    slave keytool:(null)
    slave rmiregistry:(null)
    slave jre_exports:(null)
    slave jre:(null)
    Current`bestversion is/usr/java/jdk1.6.0_26/bin/java.

  13. ganesh says:

    Hi sir i need ur help when i installing grid control on i got this error please give me reply OMS configured failed what could be the reason……

  14. Hi I have one question

    I have Installed latest java-version

    [oracle@localhost ~]$ java -version
    java version “1.6.0_45”
    Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
    Java HotSpot(TM) Client VM (build 20.45-b01, mixed mode, sharing)

    But when i am applying opatch its giving me

    OPatch 12.1.0.1.4 requires JDK 1.6 or later
    The JDK version at /oracle/product/11.2.0/db_1/jdk is 1.5.0_17
    OPatch returns with error code = 1

    Can you please suggest,why i am unable to check opatch lsinventory.

    • Gokhan Atil says:

      Are you sure you use the correct Opatch for your Oracle Home? It seems the version of your oracle database is 11gR2 but you run Opatch 12c. You need to use the latest version of Opatch for 11gR2.

      By the way, Opatch will try to use the java shipped in your Oracle home unless you say explicitly to use another one, using parameter -jdk (or -jre)

  15. Hi,

    I’m trying to install the JRE 1.7.0 , but I’m unable to locate the bin for this version in http://www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1880261.html

    So, I can’t follow your step-by-step shown above.  Could you pls advice how to get this jre-7u71-linux-x64.rpm  installed?

    Linux x64
    32.1 MB
    jre-7u71-linux-x64.rpm

    Linux x64
    44.84 MB
    jre-7u71-linux-x64.tar.gz

    • Gokhan Atil says:

      Hi Chong,

      After you downloaded the RPM file, you can use “rpm -Uvh” to upgrade Java. Don’t forget that you need to be root user to be able to use rpm tool.

      # rpm -Uvh jre-7u71-linux-x64.rpm

  16. Thanks for the article.

  17. Ashwini says:

    Hi Gokhan,

    Nice article. I appreciate your efforts.

    I have Oracle Linux 6.6 machine. I have installed jdk1.7.0_80 and jre1.7.0_80 using rpms.

    Current status of install is as shown below:

    [oracle@localhost Desktop]$ alternatives –config java

    There are 6 programs which provide ‘java’.
      Selection    Command
    ———————————————–
       1           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
       2           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
       3           /usr/lib/jvm/jre-1.5.0-gcj/bin/java
    *+ 4           /usr/java/latest/jre/bin/java
       5           /usr/java/jre1.7.0_80/bin/java
       6           /usr/java/jdk1.7.0_80/jre/bin/java

    Below are the set of ENV variables:

    export JAVA_HOME=/usr/java/jdk1.7.0_80;
    export PATH=$JAVA_HOME/bin:$PATH;
    export CLASSPATH=/usr/java/jdk1.7.0_80/bin:$CLASSPATH;

    Verifying java version

    [oracle@localhost Desktop]$ 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)

    How ever while installing Oracle ASAP 7.2 with help of jar file, it leaves message in log file as shown below:

    Could you please help me to resolve the same?

    • Gokhan Atil says:

      Hi Ashwini,

      Please check “Problem With ASAP Installation On Linux: “JVM not found” (Doc ID 1502171.1)” on My Oracle support.

  18. Manali says:

    how do i downgrade java in database level from jdk 1.7 to 1.6, the home level is downgraded but still when we query the database it gives ora-29548.Please help

Leave a Reply

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