Friday, October 27, 2006

Install Java 2 SE on Fedora Core 6

The following steps descipe how to install Java JDK 5.0 Update 9 on Fedora Core 6. Before starting though, I would like to note that I am going to install JDK in /opt/ directory.

Personally, I like using this directory when I installing new software, so that it is easier to locate and and easier to access.

  1. Download JDK from Sun Microsystems website. please ensure that you download the Linux Self-Extracting File
  2. As I used Firefox to download JDK, it automatically downloaded the JDK on my desktop. So I need to move it to /opt/ as it is the directory where I want to install JDK. to do this, log in as root and type the following command mv jdk-1_5_0_09-linux-i586.bin /opt/ && cd /opt/ which will move your download to /opt/ and change your current directory to /opt/
  3. Execute the following command chmod a+x jdk-1_5_0_09-linux-i586.bin which will make the downloaded file executable.
  4. Type ./jdk-1_5_0_09-linux-i586.bin to start the extraction process. You will be prompted with a Sun Microsystem licensce agree etc...to continue to the next page of the agreement, hit the return key until prompted to accept the agreement, answer yes to accept the agreement.
  5. You should now have a directory /opt/jdk1.5.0_09 which contains the JDK and JRE.
  6. To make things easier for us when we want to set the path to jdk, we will create a symbolic link by issuing the following command ln -s /opt/jdk1.5.0_09 jdk
Now we need to set the JAVA_HOME variable and alter the PATH as well, so that we can start developing Java applications. Using the shell, make sure that you are not logged in as root. and that you are logged in as a normal user, and follow these steps.
  1. Type cd and hit enter just to make sure that you are in your home directory.
  2. Type gedit .bash_profile & and hit enter. This will open .bash_profile in gedit so that we can easily edit the file and add additional system environment variables.
  3. Assuming that you have followed the steps above, just before the PATH variable declaration, type JAVA_HOME=/opt/jdk this will set the home directory of where we have installed JDK on our system.
  4. Add the following line after the JAVA_HOME variable declarations export JAVA_HOME
  5. Finally, alter the PATH variable so it looks like the following declaration PATH=$JAVA_HOME/bin:$PATH:$HOME/bin
Save and close .bash_profile and logout of Fedora and back in again to ensure that your alteration to the .bash_profile that affect.

Once you have logged in again, open your shell and type java -version to see if you have been successful in installing JDK on your FC6. You should see something like the following:

Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)

Java HotSpot(TM) Client VM (build 1.5.0_09-b03, mixed mode, sharing)

That concludes this tutorial. If you have any problems, please contact me and will do my best to help.

All the best.

2 comments:

Anonymous said...

Thanks a lot. I have followed your instructions and installed Sun java in fedora core 5. wondering about upgrading to fedora 6, but concerned about loosing data. Any chance of given a tutorial on how to Upgrade? thanks

Esam Gharish said...

Personally, I did a fresh install. I initially installed Fedora Core 6 on a VMWare station...just to see if everything would go smoothly. Once I managed to install it...I did a fresh install.

I found this tutorial which demonstrates how you might be able to upgrade. Though, I would recommend that you back up your data before you do anything.

http://www.brandonhutchinson.com/Upgrading_Red_Hat_Linux_with_yum.html

good luck.