How to install and configure JDK in Fedora

JDK(Java Development Kit) compiles and runs the Java programs. For many experienced programmers or the newbie it may be hard to install and configure JDK in Linux. In this tutorial, I am going to show you the most simplest and easiest way to install and configure the JDK(Java Development Kit) in your Fedora machine. I am running Fedora 16 32 bit. First, let’s take look at a simple command which will output the current version of JDK if installed in your machine.

java -version

Installing JDK:

Go to the download page of JDK in Oracle website, choose the latest JDK version, accept the license agreement and download the .rpm file(32/64 bits, depending on your machine).

jdk download for Fedora

After successfully downloading the file, go the directory where the file is downloaded and check the permission. Make the file executable by issuing the following command:

chmod u+x jdk_filename.rpm

See chmod tutorial to know about file permission.
Now install the file:

rpm -i jdk_filename.rpm

Or, you can just install graphically. Click the downloaded file, click on install, provide the password and wait till installation completes. Done!! Follow this one if command line scares you.

install jdk in Fedora

Now, JDK is successfully installed in your system. Only thing remaining is setting up the PATH and writing our first Java program.

Setting up the Path:

Open the .bashrc startup file using nano, gedit, vi or any of your favourite text editor:

nano .bashrc

and paste the following line of code at the end:

export JAVA_HOME="/usr/java/1.7.0_b147-icedtea;"

This set JAVA_HOME into environment variable.

Note: Check your java version and while setting path make sure you type the version installed in your system.

My java version is:

java version
So, I would set JAVA_HOME into environment variable as:
setting the path of jdk
JDK is successfully installed and configured.

Testing:

Let’s write our first simple Java program, compile and execute it.

public class hello {
public static void main(String[] args) {
System.out.println("Hello World");
}
}

Compile and Execute it:

first java program in Linux

JDK is successfully installed, configured and works like a charm.

Also learn to install,

  Netbeans with tomcat and glassfish server

0saves
Posted in Fedora, Linux, Linux Application | Tagged , , , , | 3 Comments

3 Responses to How to install and configure JDK in Fedora

  1. Seby UNITED STATES Mozilla Firefox Windows says:

    Hi sachit
    Nice tutorial!

  2. Txe UNITED KINGDOM Mozilla Firefox Linux says:

    Hi comm.
    I got java ver 7 update 3 as shown right below:
    [ $ java -version
    java version "1.7.0_03-icedtea"
    OpenJDK Runtime Environment (fedora-2.2.1.fc16.7-i386)
    OpenJDK Server VM (build 23.0-b21, mixed mode)]
    Do I have to remove it so that to install the lastest one (java ver 7 update 5?)
    Would anyone know to tell me the proper way to do it from cli ? Please?
    I’d really appreciate it. I go on fedora1632bit.
    Txe

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>