Installing JDK in Fedora 17 (Updated for the JDK 6.0 update 35 64 bits)

First thing we need to do is get the JDK installer
JDK Home @ Oracle.com

Once we have the installer in our local repository (as root):

chmod a+x  jdk-6u35-linux-x64-rpm.bin
./jdk-6u35-linux-x64-rpm.bin

Let’s update our alternatives:

alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_35/jre/bin/java 20000
alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.6.0_35/jre/bin/javaws 20000
alternatives --install /usr/lib64/mozilla/plugins/libjavaplugin.so libjavaplugin.so.x86_64 /usr/java/jdk1.6.0_35/jre/lib/amd64/libnpjp2.so 20000
alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_35/bin/javac 20000
alternatives --install /usr/bin/jar jar /usr/java/jdk1.6.0_35/bin/jar 20000

To confirm that our installation is successfull:

java -version

Should give us an ouptput like this:

#java -version
java version "1.6.0_35"
Java(TM) SE Runtime Environment (build 1.6.0_35-b10)
Java HotSpot(TM) 64-Bit Server VM (build 20.10-b01, mixed mode)

That’s it. Enjoy.

Advertisements

15 thoughts on “Installing JDK in Fedora 17 (Updated for the JDK 6.0 update 35 64 bits)

  1. Thank you, this really truly helped me! I could install Java just fine up until the update-alternatives part but this fixed it 100%!

  2. The comment in /etc/profile states that it is better to create the file /etc/profile.d/custom.sh and add variables there, instead of modifying /etc/profile itsself. Therefore I put the following code into /etc/profile.d/custom.sh:


    pathmunge () {
    case ":${PATH}:" in
    *:"$1":*)
    ;;
    *)
    if [ "$2" = "after" ] ; then
    PATH=$PATH:$1
    else
    PATH=$1:$PATH
    fi
    esac
    }

    JAVA_HOME=/usr/java/jdk1.6.0_21
    pathmunge $JAVA_HOME/jre/bin after
    export JAVA_HOME

    Worked like a charm, thanks!

    • Is this replacing all things I can see after the line “Next, we must add these two lines to the file: /etc/profile” in the initial post above?

    • Thanks for your comment…

      Will you please let me know what version of the JDK did you downloaded? Please paste the exact file name.

      Hint: If you downloaded the file: jdk-6u21-linux-x64-rpm.bin … then you must replace in the /etc/profile: JAVA_HOME=/usr/java/jdk1.6.0_20 for JAVA_HOME=/usr/java/jdk1.6.0_21

      And then:


      export JAVA_HOME=/usr/java/jdk1.6.0_20
      export JAVA_ALTERNATIVE_PRIORITY=16020

      Replace it with:

      export JAVA_HOME=/usr/java/jdk1.6.0_21
      export JAVA_ALTERNATIVE_PRIORITY=16021

      The rest of the steps remains the same..
      I Hope this will work for you…

      I’m working with the 64 bits version… but should work with the 32 bits version as well…

      **** I just updated the post for the JDK 6.0 update 21 64 bits version...****

      • It’s fixed already. the problem was that I downloaded .bin instead of rpm.bin version of JDK. It was a mistake in the initial post. now it seems fixed already. at least for Fedora, the right version is rpm.bin

        Thanks anyway.

  3. When I went to do the next to the last step (export the alternatives), some of them failed (javadoc, appletviewer, javah, & jar), as follows:

    [root@andes jdk]# /usr/sbin/update-alternatives –auto java
    [root@andes jdk]# /usr/sbin/update-alternatives –auto javadoc
    failed to read link /usr/bin/javadoc: No such file or directory
    [root@andes jdk]# /usr/sbin/update-alternatives –auto appletviewer
    failed to read link /usr/bin/appletviewer: No such file or directory
    [root@andes jdk]# /usr/sbin/update-alternatives –auto javah
    failed to read link /usr/bin/javah: No such file or directory
    [root@andes jdk]# /usr/sbin/update-alternatives –auto javac
    [root@andes jdk]# /usr/sbin/update-alternatives –auto jar
    failed to read link /usr/bin/jar: No such file or directory

    I assume it is because my default install on Fedora13 did not have those commands previously identified to alternatives, but I don’t know what I need to do to fix them correctly. Any help?

    Thanks.

    Andrew

    • Hi Andrew, thank you for your comment.

      Is this the first time you install JDK on your computer, or do you have a previous installation of JDK (lower version)?

      • There is a previous version of jre-1.5.0-gcj and jre-1.6.0-openjdk that were installed as part of the os install. Not sure if that answered the question – jre and openjdk? Also, I am trying to figure out alternatives — what a mess – no idea what I am doing. Below is a listing of my “alternatives –display java”. Notice that it has slaves pointing to null for the latest Sun JDK 1.6.0.21, including jre. Any help appreciated – thanks!

        alternatives –display java
        java – status is auto.
        link currently points to /usr/java/jdk1.6.0_21/bin/java
        /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java – priority 16000
        slave javaws: /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/javaws
        slave keytool: /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/keytool
        slave orbd: /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/orbd
        slave pack200: /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/pack200
        slave rmid: /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/rmid
        slave rmiregistry: /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/rmiregistry
        slave servertool: /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/servertool
        slave tnameserv: /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/tnameserv
        slave unpack200: /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/unpack200
        slave jre_exports: /usr/lib/jvm-exports/jre-1.6.0-openjdk.x86_64
        slave jre: /usr/lib/jvm/jre-1.6.0-openjdk.x86_64
        slave java.1.gz: /usr/share/man/man1/java-java-1.6.0-openjdk.1.gz
        slave keytool.1.gz: /usr/share/man/man1/keytool-java-1.6.0-openjdk.1.gz
        slave orbd.1.gz: /usr/share/man/man1/orbd-java-1.6.0-openjdk.1.gz
        slave pack200.1.gz: /usr/share/man/man1/pack200-java-1.6.0-openjdk.1.gz
        slave rmid.1.gz: /usr/share/man/man1/rmid-java-1.6.0-openjdk.1.gz
        slave rmiregistry.1.gz: /usr/share/man/man1/rmiregistry-java-1.6.0-openjdk.1.gz
        slave servertool.1.gz: /usr/share/man/man1/servertool-java-1.6.0-openjdk.1.gz
        slave tnameserv.1.gz: /usr/share/man/man1/tnameserv-java-1.6.0-openjdk.1.gz
        slave unpack200.1.gz: /usr/share/man/man1/unpack200-java-1.6.0-openjdk.1.gz
        /usr/lib/jvm/jre-1.5.0-gcj/bin/java – priority 1500
        slave javaws: (null)
        slave keytool: /usr/lib/jvm/jre-1.5.0-gcj/bin/keytool
        slave orbd: (null)
        slave pack200: (null)
        slave rmid: (null)
        slave rmiregistry: /usr/lib/jvm/jre-1.5.0-gcj/bin/rmiregistry
        slave servertool: (null)
        slave tnameserv: (null)
        slave unpack200: (null)
        slave jre_exports: /usr/lib/jvm-exports/jre-1.5.0-gcj
        slave jre: /usr/lib/jvm/jre-1.5.0-gcj
        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/jdk1.6.0_21/bin/java – priority 16021
        slave javaws: (null)
        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/jdk1.6.0_21/bin/java.

      • Andrew, for some reason, your exporting is not working…

        Please do this at command line:

        echo $JAVA_HOME

        It should output this: /usr/java/jdk1.6.0_20

        If this is not your result, please do this:

        export JAVA_HOME=/usr/java/jdk1.6.0_21
        export JAVA_ALTERNATIVE_PRIORITY=16021

        Your link is Ok.. But your priority is not..

        Please do that and review again all the steps that I have in the post and see if you missed one or got one wrong.

  4. I have verified the shell variables and they are set. The alternatives –display java shows output which confirms that at least the java entry succeded:

    /usr/java/jdk1.6.0_21/bin/java – priority 16021

    If the export had not worked then the update-alternatives –install lines for all 6 items would have failed because of too few parameters. As it is, all six install commands worked, and 2 of the 6 update-alternatives –auto worked (4 errors). All of the errors say failed to read link /usr/bin/….. I pulled the results from running the commands above (which were cut/paste from the page) from my shell window history and pasted them below. Note that the java -version was successful and shows java version “1.6.0_21” as a response.

    [root@andes jdk]# vi /etc/profile
    [root@andes jdk]# export JAVA_HOME=/usr/java/jdk1.6.0_21
    [root@andes jdk]# export JAVA_ALTERNATIVE_PRIORITY=16021
    [root@andes jdk]# /usr/sbin/update-alternatives –install /usr/bin/java java $JAVA_HOME/bin/java $JAVA_ALTERNATIVE_PRIORITY
    [root@andes jdk]# /usr/sbin/update-alternatives –install /usr/bin/javadoc javadoc $JAVA_HOME/bin/javadoc $JAVA_ALTERNATIVE_PRIORITY
    [root@andes jdk]# /usr/sbin/update-alternatives –install /usr/bin/appletviewer appletviewer $JAVA_HOME/bin/appletviewer $JAVA_ALTERNATIVE_PRIORITY
    [root@andes jdk]# /usr/sbin/update-alternatives –install /usr/bin/javah javah $JAVA_HOME/bin/javah $JAVA_ALTERNATIVE_PRIORITY
    [root@andes jdk]# /usr/sbin/update-alternatives –install /usr/bin/javac javac $JAVA_HOME/bin/javac $JAVA_ALTERNATIVE_PRIORITY
    [root@andes jdk]# /usr/sbin/update-alternatives –install /usr/bin/jar jar $JAVA_HOME/bin/jar $JAVA_ALTERNATIVE_PRIORITY
    [root@andes jdk]# /usr/sbin/update-alternatives –auto java
    [root@andes jdk]# /usr/sbin/update-alternatives –auto javadoc
    failed to read link /usr/bin/javadoc: No such file or directory
    [root@andes jdk]# /usr/sbin/update-alternatives –auto appletviewer
    failed to read link /usr/bin/appletviewer: No such file or directory
    [root@andes jdk]# /usr/sbin/update-alternatives –auto javah
    failed to read link /usr/bin/javah: No such file or directory
    [root@andes jdk]# /usr/sbin/update-alternatives –auto javac
    [root@andes jdk]# /usr/sbin/update-alternatives –auto jar
    failed to read link /usr/bin/jar: No such file or directory
    [root@andes jdk]# java -version
    java version “1.6.0_21”

    • I found out that if I get the message “failed to read link /usr/bin/: No such file or directory” removing and recreating the symlink helped.

      1. What I did was look at where the symlink was pointing
      2. Remove it if it was pointing to /etc/alternatives.
      3. Create a new symlink in /usr/bin/java-component pointing to /usr/java/jdk1.6.0.21/bin/
      4. Run /usr/sbin/update-alternatives –install /usr/bin/ $JAVA_HOME/bin/ $JAVA_ALTERNATIVE_PRIORITY
      5. Do /usr/sbin/update-alternatives –auto

  5. I know this web page gives quality depending articles or reviews and additional information,
    is there any other site which presents these kinds of things in quality?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s