I use java a lot, and i love the fact that the same program that you write and compile to windows, runs in Linux and virtually any other OS.

But i have notice that by simply running

 
yum install java

You get some other java impementation and not the Sun Java version. In theory, all those implementations work the same, but from my experience, this is not the case.

Some times some classes fail with other java implementations like openjava or something.

So i always install the original Sun Java JDK.

Steps to do that are very simple:

  1. Search in Google for “JDK download”, link here
  2. Select the first result, nowadays something like oracle.com[…] since Oracle bought Sun (at the time i wrote this: http://www.oracle.com/technetwork/java/javase/downloads/index.html)
  3. Find some link that says something like “Download JDK” – Here
  4. Select the appropriate linux version of JDK to download. (32bit or 64bit). If you don’t know what version of linux you have, run the command: uname -a. If you get something that has “x86_64” in it then you have the 64 version
  5. Right Click on the *rpm.bin and not the *.bin file and “copy link location” or something. Then go to you command line and write:
    wget [pasteUrl]

    In my case for 32bits:

     wget http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/jdk-6u24-linux-i586-rpm.bin?BundledLineItemUUID=HdaJ_hCvR9UAAAEvVDspGBK1&OrderID=cZuJ_hCvj0IAAAEvOTspGBK1&ProductID=xpeJ_hCwsEQAAAEtAMoADqmS&FileName=/jdk-6u24-linux-i586-rpm.bin
  6. Run:
    ls

    and find what is the filename of the file you just downloaded. Usually jdk.something.

  7. Run
    sh jdkfilename.bin

    (write the first few characters (usually jdk) and then press TAB and linux will automatically fill the filename for you)

  8. Press Enter and wait.
  9. run
    java -version

    . You should see something like:

    java version "1.6.0_22"
    Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
    Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)

[Αγγλικός τίτλος]
Download and install Sun Java to CentOS system