How do I create a jar file using Ant?
Author: Deron Eriksson
Description: This Ant tutorial describes how to use the jar task to build a jar file.
Tutorial created using:
Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 1.5.1
(Continued from page 1) If I execute build-jar, I see the following result in the console: Buildfile: C:\projects\workspace\team-cakes-utilities\build.xml build-jar: clean: [delete] Deleting directory C:\projects\workspace\team-cakes-utilities\bin [mkdir] Created dir: C:\projects\workspace\team-cakes-utilities\bin copy-non-java-files: compile-jar-classes: [javac] Compiling 2 source files to C:\projects\workspace\team-cakes-utilities\bin clean-jar: [delete] Deleting directory C:\projects\workspace\team-cakes-utilities\build [mkdir] Created dir: C:\projects\workspace\team-cakes-utilities\build jar: [jar] Building jar: C:\projects\workspace\team-cakes-utilities\build\team-cakes-utilities.jar BUILD SUCCESSFUL Total time: 1 second In Eclipse's Navigator view, we can verify that our classes were indeed created in our bin directory, and the jarW file was created and placed in the build directory. ![]() We can also open our jar file to verify its contents. I did this and verified that it contained the expected class files. I inspected the MANIFEST.MF file and it contained the expected results. Manifest-Version: 1.0 Ant-Version: Apache Ant 1.6.5 Created-By: 1.5.0_09-b03 (Sun Microsystems Inc.) Built-By: TeamCakes Built-On: 5-May-2007 Built-At: 02:26:20 AM PDT (Continued on page 3) Related Tutorials: |