Installing Sun Java JDK in CentOS 5.2

Installing Sun Java JDK in CentOS is not as easy as I expected.

Download the Sun Java JDK from the Java SE Downloads page.

Using your root account, or the sudo command, run the jdk-6u11-linux-i586-rpm.bin (chmod it if necessary). This will install Java packages.

Type java -version. In my case, it show gcj info instead of Sun one.
For selecting the java command, we can use the alternatives program. Use:

/usr/sbin/alternatives --install /usr/bin/java java /usr/java/latest/bin/java 2

Now run

/usr/sbin/alternatives --config java

and select option 2.

Running java -version now should show Sun JVM info.

Remember that maybe you want to do the same with javac and other Java commands.

Hope this helps.

7 Responses

  1. Since Sun started to open source their JDK Open JDK have become a great implementation that will run the most of java apps without problems.

    You may have a good reason to install old Sun’s JDK but it is something that will get obsolete as Open JDK integrates the last bits of the open sourced Sun’s JDK.

  2. Hey men, thank you… If I should find your post before!!… I uninstalled all gcj and its dependencys, later i installed Sun Java SDK… I dont’t knew about alternatives command, your post are very useful. Thanks a lot.

  3. Hola quisiera saber como puedo hacer un downgrade de jdk 6 a jdk 5 en centos 5, ya he estado busque y busque pero no encuentro comoo.

    de antemano gracias por su tiempo


  4. Thanks for the post!

  5. […] Reference: Installing Sun Java JDK in CentOS 5.2 […]

  6. Thanks, it works like a charm

  7. Thanks man, this was the best and most direct way I witnessed on the web…and it worked in a great way 🙂

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s

%d bloggers like this: