Friday, November 11, 2011

Install Sun JDK6 on Fedora

Download Java JDK6 from here: http://www.oracle.com/technetwork/java/javase/downloads/index.html

Example: jdk-6u29-linux-i586-rpm.bin

1. $ chmod +x jdk-6u29-linux-i586-rpm.bin

2. $ su -c "sh jdk-6u29-linux-i586-rpm.bin"

3.1. $ su -c "alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_29/jre/bin/java 20000"

3.2. $ su -c "alternatives --install /usr/bin/javaws javaws /usr/java/jre1.6.0_29/bin/javaws 20000"

4. Check current java, javac versions:

$ java -version
$ javac -version


5. Now you can swap between OpenJDK and Sun/Oracle JDK versions

$ su -c "alternatives --config java"

6. $ nano ~/.bash_profile

Paste into this file the following strings:

export JAVA_HOME=/usr/java/jdk1.6.0_29
PATH=$PATH:$JAVA_HOME/bin


7. $ source ~/.bash_profile

2 comments:

  1. Can you explain the difference between java and javac? And why do we need to switch between OpenJDK and Sun/Oracle JDK versions?

    ReplyDelete
    Replies
    1. I
      javac is a compiler and java is an interpreter.
      For instance, if you have file A.java which contains:

      public class A {
      public static void main (String[] args) {...}
      ...
      }


      then to run it you have to follow these 2 steps:
      1. compile this class: javac A.java
      2. run it: java A

      II
      The OpenJDK is a 100% open-source implementation of the Java language specification. The Oracle Sun JDK is largely open-source but still contains some precompiled binaries that Sun didn't have copyright to release under an open-source license.
      OpenJDK is identical to Sun JDK at 99%. But some distinctions occurred in some parts of font rendering, graphics, sound, because of the license. In addition, Sun JDK is more stable and reliable.

      Delete