Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to install Java in Linux ?

    • 0
    • 1
    • 1
    • 2
    • 0
    • 0
    • 0
    • 0
    • 471
    Comment on it

    In this article I will show you how to install the Java on Linux or it's version like CentOS/RedHat 7/6/5 and Fedora. There are lots of article on this top but most of them are misleading and confusing. I will show you simple steps to download and install the Java SDK on Linux. Before we start, you should know what is the Operating System or It's architecture.
    In my case I am using CentOS 6.6 having 64 bit architecture. How you know your Operating System ? It's so easy just run the following command :

    cat /etc/issue
    

    It will print your operating sytem name like CentOS release 6.6 (Final) and to know you OS architecture run following command:

    arch
    

    It will print x86_64, it means your system is 64-bit and if it will print i686 or i386 then your system is 32-bit. Now you know your OS and it's architecture. So let's start our steps :

    Step 1 : Go to your directory where you want to install the java. Before installing Java make sure you have write permission on that folder or should be login as super user or root user. To login as root user write following command :

    sudo -s
    

    Now go to folder, I am going to install java inside etc folder, you can change wherever you want.

    # cd /etc
    

    Step 2 : Create new folder called Java (Not mandatory to create folder):

    # mkdir java
    

    Change directory to new directory:

     # cd /etc/java/
    

    Step 3: Download the JDK using command

    For 64 bit system use following command :

    # wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-linux-x64.tar.gz"
    

    For 32 bit system use following command :

    # wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/7u72-b14/jdk-7u72-linux-i586.tar.gz"
    

    Step 4: After completing the download, extract archive using following command.

    # tar xzf jdk-7u72-linux-x64.tar.gz
    

    Step 5: Installing JAVA

    After extracting java archive file, we can now set JAVA_HOME and System PATH. To set it for your system, you can issue the following commands from the Command line:

    # JAVA_HOME=/etc/java/jdk1.7.0_72
    # export JAVA_HOME
    # PATH=$JAVA_HOME/bin:$PATH
    # export PATH
    

    To Set the path permanently, open the .bashrc system file and edit it as follows:

    vi ~/.bashrc
    

    add the following lines in this file

    export JAVA_HOME=/etc/java/jdk1.7.0_72
    export PATH=$PATH:$JAVA_HOME/bin
    

    Now whenever you access the java from command prompt it will set the class path automatically.

    Step 6: Check JAVA Version

    The java is installed and all system variable's are already set, now it's time to check that java is installed properly or not. Write the following command on your command line:

    # java -version
    

    If you found following output, it means java is installed and ready to use:

    java version "1.7.0_72"
    Java(TM) SE Runtime Environment (build 1.7.0_72-b14)
    Java HotSpot(TM) 64-Bit Server VM (build 24.72-b04, mixed mode)
    

    If not then please check the steps again, or check your PATH and JAVA_HOME system variables are set or not.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: