Well, the truth is, there is no one step way to do this. This is what users tend to do:

  • Extract the Jar file
  • Delete the Jar file
  • Run the Jar command to re-create the Jar file.

So yeah, I can make a batch file for this but since I have no idea how to make one, I decided to use Ant.

Here is my script.

The following explains the steps that the build script executes:

  • Go over all folders recursively to look for existing jar files.
  • Extracts them one by one in a folder name that is the name of the Jar file + “_folder”.
  • Delete the old Jar file
  • Re-create the Jar file
  • Delete the folder

That’s it! Simply put the build script file in any folder you want it to start searching for Jar files and it does the rest.

To fix this Ant error message that confuses users into thinking that the cause of the error is somewhere in the foreach tag, do the following steps:

  1. Go to  the download page of ant-contrib at http://sourceforge.net/projects/ant-contrib/files/
  2. Download ant-contrib-0.3 and copy ant-contrib-0.3.jar to the lib folder where your Apache Ant is installed.
  3. In your build.xml file, make sure you declare this XML

That is all!

If you just recently deployed Ant into your system and you encounter this error message when you build your application, “Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK …”, chances are that you set up the path in your Windows environment incorrectly.

You may have placed the full path of the Java directories instead of making use of the JAVA_HOME environment variable. To fix the problem do this


The same goes to your ANT_HOME environment variable


That should work.

Related Posts Plugin for WordPress, Blogger...