Skip to content
Bots!
Bots!
  • About
    • Myself
    • আমার দোয়া
  • Bookmarks
    • Bookmarks
    • My OCI Bookmarks
    • Useful Proxmox Commands & Links
    • Learning Nano
    • Useful Sites
    • Useful Virtualbox Command
    • Useful MySQL Command
    • Useful Linux Command
    • BTT-CAS
  • Resources
    • Webinar on Cloud Adoption for Project Managers
  • Photos
  • Videos
  • Downloads
Bots!

How to install Java SDK (1.6) and Apache Ant (1.7) on CentOS

Rumi, November 18, 2011November 18, 2011

I had enough with some package managers or alternative ways of installing Java on a server which is running CentOS (RHEL) 4.4 . I think the most straight forward way is the following. I promise by the end of this post you will have Java and Apache Ant running on you server!

SETUP JAVA

Step 1: Download Java SDK for Linux (I have used the .bin file)

Step 2: upload the .bin file to your server – I have picked the following folder /usr/lib/
So it would be /usr/lib/jdk-6u1-linux-i586.bin (this is JDK1.6 update 1 for my case maybe when you read this post is jdk1.7).

Step 3: Unpack – extract the bin file contents of the bin file

    > chmod 777 jdk-6u1-linux-i586.bin
    > ./jdk-6u1-linux-i586.bin

Step 4: Follow the instructions and type yes when prompted to do so! After unpacking you should have the following folder /usr/lib/jdk1.6.0_01/

Step 5: Go to the /etc/alternatives folder and create a sym link to the java executable

    > cd /etc/alternatives
    > ln -s /usr/lib/jdk1.6.0_01/bin/java java

Step 6: Go to the /usr/bin folder and create a sym link pointing to the sym link of alternatives
(there are 2 levels of sym links that may prove to be handy in case we change to a new version after a while)

    > cd /usr/bin/
    > ln -s /etc/alternatives/java /usr/bin/java

Yes this is it you may test if Java( runtime) is there by typing

    > java -version

Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)

SETUP JAVA_HOME

Step 1: Based on the installation above I would like to create another sym link to point on the jdk folder so

    > cd /etc/alternatives
    >ln -s /usr/lib/jdk1.6.0_01/ /etc/alternatives/jdk

So if I do a

    > cd /etc/alternatives/jdk
    >ls

I get the contents of the actuall jdk160 folder

Step 2: Set the JAVA_HOME variable globally!

    > cd /etc/
    > vi ./profile

(hope you know the basics of vi)

Step 2.1 :there add a new line with the following
JAVA_HOME ="/etc/alternatives/jdk"

Step 2.2: and change the existing line
from
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
to
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC JAVA_HOME

Step 3: you should restart your bash session in order the new variable to be loaded just check

    > echo $JAVA_HOME
    /etc/alternatives/jdk

Done!

SETUP APACHE ANT

Step 1: Go to the /usr/lib/ folder and wget apache ant gz file

    >cd /usr/lib/
    > wget http://apache.forthnet.gr/ant/binaries/apache-ant-1.7.0-bin.tar.gz

Step 2: When it is finished unpack the archive

    >gzip -d apache-ant-1.7.0-bin.tar.gz
    > tar -xvf apache-ant-1.7.0-bin.tar

You should end up with a folder /usr/lib/apache-ant-1.7.0/

Step 3: Lets create some Sym links again for the ant executable

    >ln -s /usr/lib/apache-ant-1.7.0/bin/ant /etc/alternatives/ant

Step 4: :Lets create some Sym links for the ant home directory

    >ln -s /usr/lib/apache-ant-1.7.0/ /etc/alternatives/anthome

Step 5: Lets create a sym link to the /usr/bin folder for ant

    > ln -s /etc/alternatives/ant /usr/bin/ant

Step 6: Add the ANT_HOME variable like we did with java home

    >cd /etc/
    >vi ./profile

Step 6.1 : Add the following line
ANT_HOME="/etc/alternatives/anthome"

Step 6.2 : add ANT_HOME to the export statement
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC JAVA_HOME ANT_HOME

Restart your terminal session and now if you type:

    >ant -version
    Apache Ant version 1.7.0 compiled on December 13 2006

    >echo $ANT_HOME
    /etc/alternatives/anthome

Done!

Src: http://javapapo.blogspot.com/2007/04/how-to-install-java-sdk-6-and-apache.html

Administrations Configurations (Linux) AntCentOSJava

Post navigation

Previous post
Next post

Leave a Reply Cancel reply

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

Myself…

Hi, I am Hasan T. Emdad Rumi, an IT Project Manager & Consultant, Virtualization & Cloud Savvyfrom Dhaka, Bangladesh. I have prior experience in managing numerous local and international projects in the area of Telco VAS & NMC, National Data Center & PKI Naitonal Root and CA Infrastructure. Also engaged with several Offshore Software Development Team.

Worked with Orascom Telecom-Banglalink, Network Elites as VAS partner, BTRC, BTT (Turkey) , Mango Teleservices Limited and Access to Informaiton (A2I-UNDP)

Currently working at Oracle Corporation as Principal Technology Solution and Cloud Architect.

You can reach me [h.t.emdad at gmail.com] and I will be delighted to exchange my views.

Tags

Apache Bind Cacti CentOS CentOS 6 CentOS 7 Debain Debian Debian 10 Debian 11 Debian 12 DKIM Docker endian icinga iptables Jitsi LAMP Letsencrypt Linux Munin MySQL Nagios Nextcloud NFS nginx pfsense php Postfix powerdns Proxmox RDP squid SSH SSL Ubuntu Ubuntu 16 Ubuntu 18 Ubuntu 20 Varnish virtualbox vpn Webmin XCP-NG zimbra

Topics

Recent Posts

  • Install Jitsi on Ubuntu 22.04 / 22.10 April 30, 2025
  • Key Lessons in life April 26, 2025
  • Create Proxmox Backup Server (PBS) on Debian 12 April 19, 2025
  • Add Physical Drive in Proxmox VM Guest April 19, 2025
  • Mount a drive permanently with fstab in Linux April 16, 2025
  • Proxmox 1:1 NAT routing March 30, 2025
  • Installation steps of WSL – Windows Subsystem for Linux March 8, 2025
  • Enabling Nested Virtualization In Proxmox March 8, 2025
  • How to Modify/Change console/SSH login banner for Proxmox Virtual Environment (Proxmox VE / PVE) March 3, 2025
  • Install Proxmox Backup Server on Debian 12 February 12, 2025

Archives

Top Posts & Pages

  • Install Jitsi on Ubuntu 22.04 / 22.10
©2025 Bots! | WordPress Theme by SuperbThemes