Sunday, February 5, 2012

Installing ANT on Windows 7

ANT is popular build tool used in java based application development.

ANT package is not installable binary.  It is .zip file.  I have downloaded latest version, which happens to be 1.8.2. All the instructions below assumed this version.  If you have downloaded some other version, then the version number would be different.

http://apache.mirrors.redwire.net//ant/binaries/apache-ant-1.8.2-bin.zip

Unzip the file into a directory. I  have extracted this into c:\"Program Files".

It gets extracted to c:\"Program Files"\apache-ant-1.8.2\ directory.

You need to do two things before you start using 'ant'.

1. Setting up the environment variable ANT_HOME.   On Windows 7,  it is simple.  Do following steps.
  •  Go to Windows "Start" (Left lower corner windows logo).
  •  Right Click on "Computer".
  •  On the result screen,  click on "Properties".  A new screen appears.
  •  On left navigation panel,  click on "Advance system settings".  If you have logged in as normal users into windows,  it would ask for administrator password.  Give your password.  A new screen titled "system properties" appears.
  • In "Advanced" tab,  click on "Environment variables" button.
  • There user variable can be added with variable name as ANT_HOME and value as c:\Program Files\apache-ant-1.8.2

Second step is to add "c:\program files\apache-ant-1.8.2\bin to the PATH variable.
  • On the screen that results by clicking on 'Environment Variables' button as described above, you can see 'System variables' box.  PATH variable would have been there already.  Double click on it and modify the path variable by appending c:\Program Files\apache-ant-1.8.2\bin.
Verify that above steps are done properly by executing 'ant' command from the command prompt.

  • On Windows "Start",  in "search programs and files' dialog box,  type "command" (no double quotes).   It throws up a command prompt screen.
  • Type 'ant' at the prompt.
  • If it says, it could not find the command,  then there is some issue in setting up the path variable.
  • If it says ANT_HOME is wrong,  then ANT_HOME environment variable is not set.
  • If you find tools.jar is not found error, it means that you did not install the Java SE JDK.  Install Java SE JDK and set the JAVA_HOME environment variable pointing to newly installed JDK.  To set the environment variable, follow the similar steps followed for setting up the ANT_HOME.

Saturday, February 4, 2012

Ubuntu 11.10 - Installing Java 7


Download Java SE SDK from java.oracle.com website.  In my case, I needed to download 32 bit version of Linux. Hence I used this link:  http://download.oracle.com/otn-pub/java/jdk/7u2-b13/jdk-7u2-linux-i586.tar.gz

I downloaded this /tmp directory.

Extract the files first;

Execute this from the ubuntu terminal shell:  sudo tar -zvxf  jdk-7u2-linux-i586.tar.gz
It creates a directory called jdk1.7.0_02 (This could be different based on the version you download).

Now we need to link it at proper place in ubuntu. First move the jdk into /usr/lib/jvm directory

Execute this from Ubuntu shell :  sudo mv jdk1.7.0_02 /usr/lib/jvm

Make the ubuntu know about this java: 

First check if there is any java jdk installed before.
Execute this command from ubuntu shell:  sudo update-alternatives --config java

Above command will list down currently installed java versions and their priorities.  In my case, there were no previous installations of java.

Execute this command from ubuntu shell to make this java known to Ubuntu:  sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_02/jre/bin/java 1

Above command not only creates a symbolic link at /usr/bin/java and also informs the software manager of ubuntu of the package name "java".   Since it is my first installation of java in this machine,  I gave priority 1 to above command.

Verification;

Check the java installation by executing following commands at shell:
sudo update-alternatives --config java
Above command should show the java you have just installed.

Finally execute following to ensure that the version you see is the one you  have just installed
java -version
Above command prints the java version.