How To Install JDK 6 / Java SE 6 (+ Tomcat) in Fedora Core 6 / Fedora 7 in 5 Minutes

By Angsuman Chakraborty, Gaea News Network
Tuesday, August 7, 2007

JDK 6Fedora Core developers make it rather hard to install and properly configure Sun’s JVM. All said and done Sun’s JVM (comes with JDK) is the best JVM implementation out there; not to mention that it is the reference implementation. Here is how you can easily install JDK 6 / Java SE 6 in 5 minutes or less. Here are the steps:

1. Login as root

2. First you need to download it from here. This works fine from GUI browsers like Firefox, Internet Explorer or Safari. However Sun makes it very hard (from java.sun.com) to download it for Linux console users (like those trying to install on their dedicated web server). You cannot access the download link from text based lynx browser. Fortunately there is a way. I found a secret location for you to easily download JDK 6 using wget or curl (console apps). This is also very useful if you are planning to use any download accelerators. The current binary (32 bit version) is here. This link will surely change with time so it is better to browse to the link above and then access this link from that page.

Download it using wget or curl. The command, for example, today will be:
wget https://www.java.net/…/jdk-6u2-ea-bin-b02-linux-i586-12_apr_2007-rpm.bin

Note: The link has been truncated for brevity, however it is hyperlinked to the actual link.

3. Now change the permission of the downloaded file to 755 like this:
chmod 755 jdk-6u2-ea-bin-b02-linux-i586-12_apr_2007-rpm.bin

4. Then run it:
./jdk-6u2-ea-bin-b02-linux-i586-12_apr_2007-rpm.bin

You will need to type yes to indicate your acceptance to their agreement and the installation will complete on its own. Unfortunately you are not yet done. Type java -version on the command line and you will see that it still points to the crappy old JVM from gcj.

5. Now you need to find the actual location of your JDK installation and indicate to Fedora to accept your choice.

Type the following:
updatedb;locate javac |grep bin

You will see an entry like this:
/usr/java/jdk1.6.0_02/bin/javac

Here /usr/java/jdk1.6.0_02 is the actual JAVA_HOME for your machine. Note this as you will need it to run the future commands.

Now you need to run the alternatives command to instruct Fedora to recognize Sun’s JVM.
alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_02/bin/java 100
alternatives --install /usr/bin/jar jar /usr/java/jdk1.6.0_02/bin/jar 100
alternatives --install /usr/bin/javac javac /usr/java/jdk1.6.0_02/bin/javac 100

You can do this for other Java executables too, should you need them, following the same pattern.

Note: If alternatives is not in your path then use locate alternatives to locate it.

Finally you should configure alternative to use Sun’s JVM as the default JVM. To do this type:
/usr/sbin/alternatives --config java

This will present you with at least 2 options. Choose the one for Sun’s JVM. Similarly repeat the process for other commands.

Now you are done configuring Fedora for the most part. Type java -version and you should see something like this:

java version "1.6.0_02-ea”
Java(TM) SE Runtime Environment (build 1.6.0_02-ea-b02)
Java HotSpot(TM) Client VM (build 1.6.0_02-ea-b02, mixed mode, sharing)

Note: This works for most part, except Tomcat. The default installation of Tomcat has been hardwired to use GCJ. I changed the configuration file and it didn’t help. My solution for Tomcat is to ditch Fedora’s version and install directly from site. It works like a charm. Set JAVA_HOME to the value we found above and you are done.

Discussion

Danilo
April 1, 2010: 10:17 am

Awesome tutorial!
I’m getting started with Linux, and this was very helpful!
Thanx a lot!


umesh
January 28, 2010: 11:31 pm

plz help to php conectiviti in fedora7

September 16, 2009: 11:41 pm

Whew! Thanks…I finally get links to the JDK binary locations for wget use. Glad to see you’re updating your links considering this was posted in 2007 :) More power! :D


martin kollubke
August 6, 2009: 9:20 am

Awesome how-to, worked fine!


John
June 17, 2009: 3:52 pm

I just successfully installed Java 6 and Tomcat 6 on Fedora 11. Thanks a lot for this well written, witty guide :)


anon
April 30, 2009: 12:16 pm

This is a fantastic guide! Well done. I’m completely useless with linux of any kind and I managed to upgrade our production server all by myself. You ROCK!


Dan
April 13, 2009: 4:51 pm

The question in French translates approximately to:

Thanks for the information.

Using Fedora Core 9, I have a problem, a few problems even…

First of all, I don’t have the latest JDK version…

When I click on the link to get the localized version I get the following message: “bash: localiser: command not found”…

If you have an idea…

October 9, 2008: 9:39 am

@Aferkiw

I am sorry but I don’t understand French. Do you speak English?


Aferkiw
October 9, 2008: 6:28 am

Merci pour les infos.

Cependant sur le fedore core 9, j’ai un probleme, et même plusieurs problemes …

Tout dabord je n’ai pas la dernière version du JDK …

D’autre part quand je tappe la commande pour localiser j’ai le message suivant “bash: localiser: command not found” …

Si vous avez une idée ….


Carpii
September 8, 2008: 7:01 pm

Thanks so much, Ive spent hours on getting java working, just to install RED5.

Other guides suggest using JPackage repo, which doesnt seem to include support the latest jdk versions, and the end result is that interactive ‘alternatives’ wont pick up the official java paths

This worked a treat. Thanks again!

June 6, 2008: 3:19 pm

[...] is an excellent article about installing jdk6 on FC6 which works for FC3 as [...]

May 23, 2008: 2:54 pm

[...] Thanks to Angsuman Chakraborty, the author of: How To Install JDK 6 / Java SE 6 (+ Tomcat) in Fedora Core 6 / Fedora 7 in 5 Minutes. [...]

February 24, 2008: 8:34 am

Thanks a lot for this useful information
This was a great help and probably saved me a lot of time


Bala
December 30, 2007: 4:07 pm

Alternate solution to download SUN JDK to remote Fedora server

1) Login to Fedora server, install SFTP on Fedora and follow

a. yum install vsftpd
b. service vsftpd start
c. service vsftpd status

2) Download linux version of SUN JDK from your windows desktop

3) Install any Free SFTP client (winSCP) on your client desktop and start a new session. Use your Fedora credentials

4) Transfer the SUN JDK file to the Fedora server and continue with JDK installation process

5) In case, you don\\\’t want SFTP service anymore,

service vsftpd stop


Tim T
October 13, 2007: 9:34 am

Hi,
I am running plesk 8.2.1 and so did not want to have to re install Tomcat, however I managed to overcome this by making 4 changes to the /usr/bin/dtomcat5 file.
Basically I changes the following lines

_RUNJAVA=”JAVA_HOME”/bin/java to:
_RUNJAVA=/usr/java/jdk1.6.0_05/bin/java

this change was also made to the following attributes in this file:
_RUNJDB
_RUNJAVAC
CLASSPATH

I know this is not a pretty solution however works


anees
September 18, 2007: 5:42 am

hi there,

if nothing works try putting the java path on to the ‘.bash_profile’ and modify the path. also the java path should come first than others.

–aneeskA

September 3, 2007: 7:55 am

hi,

on fedora or redhat, change the JAVA_HOME variable in /etc/sysconfig/tomcat5 rather than /etc/tomcat5/tomcat5.conf. tomcat is NOT hard-wired to use GCJ, the config file is just in a (RH standard) different place.

regards,
sb


Diederik
August 31, 2007: 7:27 am

Thanks, it worked like a charm on my Fedora 7 box!


Michael
August 13, 2007: 10:05 am

You can do the download with Lynx, it is just a pain. Make sure you select to accept the license agreement by marking the [x] above the download link.

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :