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
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/alternativesStep 6: Go to the /usr/bin folder and create a sym link pointing to the sym link of alternatives
> ln -s /usr/lib/jdk1.6.0_01/bin/java java
(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)
Step 1: Based on the installation above I would like to create another sym link to point on the jdk folder so
> cd /etc/alternativesSo if I do a
>ln -s /usr/lib/jdk1.6.0_01/ /etc/alternatives/jdk
> cd /etc/alternatives/jdk
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
Step 2.2: and change the existing line
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC
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_HOMEDone!
SETUP APACHE ANT
Step 1: Go to the /usr/lib/ folder and wget apache ant gz file
> 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.gzYou should end up with a folder /usr/lib/apache-ant-1.7.0/
> tar -xvf apache-ant-1.7.0-bin.tar
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/antStep 4: :Lets create some Sym links for the ant home directory
>ln -s /usr/lib/apache-ant-1.7.0/ /etc/alternatives/anthomeStep 5: Lets create a sym link to the /usr/bin folder for ant
> ln -s /etc/alternatives/ant /usr/bin/antStep 6: Add the ANT_HOME variable like we did with java home
Step 6.1 : Add the following line
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:
Apache Ant version 1.7.0 compiled on December 13 2006
* I am not a linux sys admin so..maybe you can do it better..though the steps above gave me in 10 minutes a real Java and Ant setup for my CentOS 4.4 linux server.
*If you don't feel comfortable with some of the commands like the symbolic link creation or the use of vi then don't do it - I have included some links on each command!
*Yes there are some package managers that do it on their own way..I know!
*This procedure it can be applied I suppose to all the linux flavors since its not package-manager dependant
*When you see the > i just used to to show the terminal..do not write it your self most probably will be [root@localhost ~]
* I used root user to do the setup
I hope it helps!