Ask Your Question

[Sticky] How do I install oracle Java?

asked 2014-12-12 00:28:53 -0500

yasharne gravatar image

updated 2019-01-10 07:29:55 -0500

hhlp gravatar image

hi i have just installed fedora 21,I have installed oracle jdk8 from its rpm pakage with no failure but when i type alternatives --config java i just see one choice which is openjdk, i tried to install oracle jdk pakage again but it says

package jdk1.8.0_20-2000:1.8.0_20-fcs.x86_64 is already installed

edit retag flag offensive close merge delete

4 Answers

Sort by ยป oldest newest most voted

answered 2014-12-12 03:39:44 -0500

updated 2016-02-08 14:53:14 -0500

To extend on @vtrfny 's answer here is my ultimate guide on how to install Oracle JDK 8 once for all.

How to install Oracle JDK 8 on Fedora 21

  • Download Oracle JDK from here and install using following command.

    • Install

      rpm -ivh jdk-<version>-linux-x64.rpm
    • Upgrade

      rpm -Uvh jdk-<version>-linux-x64.rpm

This will install Oracle JDK 8 in /usr/java/jdk<version>.

  • Choose Alternatives

    • Config

      alternatives --config java
      alternatives --config javac
      alternatives --config javaws
    • Verify

       $ alternatives --list | grep /usr/java
       javaws  manual  /usr/java/jdk1.8.0_74/bin/javaws
       javac   manual  /usr/java/jdk1.8.0_74/bin/javac
       java    manual  /usr/java/jdk1.8.0_74/jre/bin/java
  • Verify Installation

    $ java -version
    java version "1.8.0_74"
    Java(TM) SE Runtime Environment (build 1.8.0_74-b02)
    Java HotSpot(TM) 64-Bit Server VM (build 25.74-b02, mixed mode)
    $ javac -version
    javac 1.8.0_74

Information below is no longer required.

Starting with version 8u40, the JDK installation is integrated with the alternatives framework and after installation, the alternatives framework is updated to reflect the binaries from the recently installed JDK. Java commands such as java, javac, javadoc, and javap can be invoked from the command line. Source - Oracle JDK Installation Instructions

  • Setup Alternatives

    su -
    alternatives --install /usr/bin/java java /usr/java/default/jre/bin/java 200000
    alternatives --install /usr/bin/javaws javaws /usr/java/default/jre/bin/javaws 200000
    alternatives --install /usr/lib64/mozilla/plugins/ /usr/java/default/jre/lib/amd64/ 200000
    alternatives --install /usr/bin/javac javac /usr/java/default/bin/javac 200000
    alternatives --install /usr/bin/jar jar /usr/java/default/bin/jar 200000
  • Choose Alternatives

       su -
       alternatives --config java
       alternatives --config javaws
       alternatives --config
       alternatives --config javac
       alternatives --config jar
  • Errors

    failed to read link /usr/bin/javaws: No such file or directory`

For solution see this blogpost.

edit flag offensive delete link more

answered 2014-12-12 02:17:25 -0500

vtrefny gravatar image

You need to add it to list of alternatives first:

alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_25/jre/bin/java 200000
edit flag offensive delete link more


thank you so much, can you explain what 200000 means? thanks

yasharne gravatar imageyasharne ( 2014-12-12 03:24:25 -0500 )edit

The number is priority (higher is better, so 200000 is just some random really high number).

vtrefny gravatar imagevtrefny ( 2014-12-12 03:48:38 -0500 )edit

answered 2018-11-17 08:30:49 -0500

hhlp gravatar image

How to install Oracle JDK 11 on Fedora

Download Oracle JDK from here and install using following command:

  1. Install
rpm -ivh jdk-<version>-linux-x64.rpm
  1. Upgrade
rpm -Uvh jdk-<version>-linux-x64.rpm

This will install Oracle JDK /usr/java/jdk<version>.

  1. Check current java, javac versions
java -version
  1. If you have more than one, Swap between OpenJDK and Sun/Oracle Java JDK/JRE 6, 7, 8, 9, 10, 11 versions java
alternatives --config java
alternatives --config javac

Note: java with [+] is currently on use

Note : Java and Firefox Browser *

edit flag offensive delete link more

answered 2015-05-07 23:03:23 -0500

cheesiechimp gravatar image

For configuring alternatives, I follow a slightly different approach to @donniezazen's steps.

Below approach is useful for me as I frequently use other components during Java development.

sudo /usr/sbin/alternatives  \
  --install /usr/bin/java      java        /usr/java/jdk1.8.0_45/bin/java          20000 \
  --slave /usr/lib/jvm/java_home_dir java_home_dir /usr/java/jdk1.8.0_45 \
  --slave /usr/bin/javadoc     javadoc     /usr/java/jdk1.8.0_45/bin/javadoc \
  --slave /usr/bin/javaws      javaws      /usr/java/jdk1.8.0_45/bin/javaws \
  --slave ... add those you need ... keytool / orbd / servertool / rmiregistry ... etc

Full alternatives command is here

Also configure such that JAVA_HOME is switched each time alternatives is used.

sudo vim /etc/profile.d/  

# /etc/profile.d/
# Set PATH for Sun JDK

export JAVA_HOME=`realpath /etc/alternatives/java_home_dir`

export PATH

Don't forget to make the script executable

sudo chmod +x /etc/profile.d/
edit flag offensive delete link more


Slightly improved "full" command here , it's easier to edit the path to fit your situation.

Quintesse gravatar imageQuintesse ( 2015-05-19 10:47:02 -0500 )edit

@cheesiechimp I don't really understand master slave thing of alternatives. I like the idea of switching alternatives. I will look into it. Thanks.

sudhirkhanger gravatar imagesudhirkhanger ( 2015-05-21 10:23:44 -0500 )edit

Question Tools



Asked: 2014-12-12 00:28:53 -0500

Seen: 59,244 times

Last updated: Nov 17 '18