How to install Apache ANT

Here, I would like to explain you about how to build a Java Project using Apache ANT(Another Neat Tool). Maven is also a build tool but I prefer ANT over Maven. A build tool like ANT, can be used to automate certain repetitive work, not only to build Java projects. When creating jar files, compiling source codes , etc a build tool plays a major role.

So, enough talking about the tool. let’s get our hands dirty. First we have to install Apache ANT.

Linux Users – type in the terminal, apt-get install ant to install it.

Windows Users –

  • Download the ZIP file Apache ANT from this site.
  • Extract the file into any location (for this Example let’s assume that the zip file is extracted to the C drive).
  • Go to Environmental Variables Menu (Right click on the My Computer > Properties > Advanced System Settings > Environmental Variables)
  • Add a new User Variable (Not a System Variable). Variable Name – ANT_HOME , Variable Value – C:\apache-ant-1.8.2
  • Add another User Variable. Variable Name – JAVA_HOME, Variable Value – “Path to Java JDK”
  • Add “C:\apache-ant-1.8.2\bin” to Path variable (Path Variable is at the System Variables Section)

Now you are done with the installation part. To check whether the ANT is running without any errors, Open Command Prompt and type ant -version and there will be a massage displaying the compilation date. If not, try again. 🙂

How to get the focus to a specific field in GUI in Java

When working with Graphical User Interfaces(GUI) the main thing you should keep in your mind is user friendliness. Think about an example that you try to get some details from the user for different text fields. When the user hits the save button we first have to validate the fields as to check the correctness of data. Then, we found that one data in a text field is incorrect. So we have to send a message to the user indicating that there is an error in that particular field. What if we can focus that text field to the user. Is it very friendly, right? It’s just a simple thing. Try this out

//code for the action performed event of the save button
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
// save the details

private booleanvalidateTextFields(){
JOptionPane.showMessageDialog(null, "The data you entered is incorrect", "Warning", 1);
return false;