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:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
su - root chmod +x jdk-6u26-linux-i586-rpm.bin ./jdk-6u26-linux-i586-rpm.bin Unpacking... Checksumming... Extracting... UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu). inflating: jdk-6u26-linux-i586.rpm inflating: sun-javadb-common-10.6.2-1.1.i386.rpm inflating: sun-javadb-core-10.6.2-1.1.i386.rpm inflating: sun-javadb-client-10.6.2-1.1.i386.rpm inflating: sun-javadb-demo-10.6.2-1.1.i386.rpm inflating: sun-javadb-docs-10.6.2-1.1.i386.rpm inflating: sun-javadb-javadoc-10.6.2-1.1.i386.rpm Preparing... ################################### [100%] 1:jdk ################################### [100%] Unpacking JAR files... rt.jar... jsse.jar... charsets.jar... tools.jar... localedata.jar... plugin.jar... javaws.jar... deploy.jar... Installing JavaDB Preparing... ################################### [100%] 1:sun-javadb-common ################################### [ 17%] 2:sun-javadb-core ################################### [ 33%] 3:sun-javadb-client ################################### [ 50%] 4:sun-javadb-demo ################################### [ 67%] 5:sun-javadb-docs ################################### [ 83%] 6:sun-javadb-javadoc ################################### [100%] Java(TM) SE Development Kit 6 successfully installed. Product Registration is FREE and includes many benefits: * Notification of new versions, patches, and updates * Special offers on Oracle products, services and training * Access to early releases and documentation Product and system data will be collected. If your configuration supports a browser, the JDK Product Registration form will be presented. If you do not register, none of this information will be saved. You may also register your JDK later by opening the register.html file (located in the JDK installation directory) in a browser. For more information on what data Registration collects and how it is managed and used, see: http://java.sun.com/javase/registration/JDKRegistrationPrivacy.html |
Is it done? Let’s check it:
|
1 2 3 4 5 6 7 8 |
java -version java version "1.4.2" gij (GNU libgcj) version 4.1.2 20080704 (Red Hat 4.1.2-50) Copyright (C) 2006 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
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:
|
1 2 |
/usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_26/bin/java 16026 |
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:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
/usr/sbin/alternatives --display java java - status is auto. link currently points to /usr/java/jdk1.6.0_26/bin/java /usr/lib/jvm/jre-1.4.2-gcj/bin/java - priority 1420 slave keytool: /usr/lib/jvm/jre-1.4.2-gcj/bin/keytool slave rmiregistry: /usr/lib/jvm/jre-1.4.2-gcj/bin/rmiregistry slave jre_exports: /usr/lib/jvm-exports/jre-1.4.2-gcj slave jre: /usr/lib/jvm/jre-1.4.2-gcj /usr/java/jdk1.6.0_26/bin/java - priority 16026 slave keytool: (null) slave rmiregistry: (null) slave jre_exports: (null) slave jre: (null) Current `best' version is /usr/java/jdk1.6.0_26/bin/java. |
Let’s check the version of java:
|
1 2 3 4 5 |
java -version java version "1.6.0_26" Java(TM) SE Runtime Environment (build 1.6.0_26-b03) Java HotSpot(TM) Client VM (build 20.1-b02, mixed mode, sharing) |
You can also change the alternative of Java manually:
|
1 2 3 4 5 6 7 8 9 10 |
/usr/sbin/alternatives --config java There are 2 programs which provide 'java'. Selection Command ----------------------------------------------- 1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java *+ 2 /usr/java/jdk1.6.0_26/bin/java Enter to keep the current selection[+], or type selection number: |
Type the number of the alernative you want to use and hit enter key.
14 Responses to “How to Install/Update Java (JDK) on Oracle Linux”


Thanx from Spain!!!
Your post has saved me.
I’m glad to hear that it helped you.
That worked a treat, thank you.
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
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.
You’re a life saver, thanks a lot
You are welcome!
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?
It looks like a DNS problem. You may try to download it on your PC and then transfer the RPM file to the server.
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 .
Great doc, helped me clear a hurdle. Shared it w/ my team. Many thanks.
You are welcome. I’m glad to hear that it helps.
ü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 ).
Hyp, ben sadece amatör olarak Java programlama ile uğraşıyorum. Nokia Asha’ya göz attığım kadarıyla Java ME istiyor. Onu yükledin mi?
http://www.oracle.com/technetwork/java/javame/index.html