Ask Your Question

Revision history [back]

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

      su -c 'rpm -ivh jdk-8u25-linux-x64.rpm'
      
    • Upgrade

      su -c 'rpm -Uvh jdk-8u25-linux-x64.rpm'
      

This will install Oracle JDK 8 in /usr/java/jdk1.8.0_25.

  • 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/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/default/jre/lib/amd64/libnpjp2.so 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 libjavaplugin.so.x86_64
       alternatives --config javac
       alternatives --config jar
    

If you have errors like failed to read link /usr/bin/javaws: No such file or directory see this blogpost.

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

      su -c 'rpm rpm -ivh jdk-8u25-linux-x64.rpm'
      jdk-<version>-linux-x64.rpm
      
    • Upgrade

      su -c 'rpm rpm -Uvh jdk-8u25-linux-x64.rpm'
      jdk-<version>-linux-x64.rpm
      

This will install Oracle JDK 8 in /usr/java/jdk1.8.0_25/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/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/default/jre/lib/amd64/libnpjp2.so 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 libjavaplugin.so.x86_64
       alternatives --config javac
       alternatives --config jar
    

If you have errors like

  • Errors

    failed to read link /usr/bin/javaws: No such file or directory directory`
    
  • For solution see this blogpost.