Showing posts with label Getting started with ANT. Show all posts
Showing posts with label Getting started with ANT. Show all posts

Wednesday, September 21, 2011

Create a Executable jar file from the command line or ANT build, Build Simple ANT File

Here i am posting how to make executable jar file from the command line as well through ANT tool, then how to run that executable jar file from the command prompt

This is the simple way to create executable jar file.

Step 1 : create folder inside your respective directory [Ex: c:/simple_java/src>]
Step 2 : create java file/files under this project[Package name is optional]
Ex: HelloWorld.java ,Person.java
under com.siva pacakage
Ex: c:/simple_java/src/com/siva>HelloWorld.java
Person.java
compile : c:/simple_java/src>javac com/siva/*.java

Step 3 : create one MANIFEST.MF or manifest.txt
under src folder.[this file can be created any place in your computer]

Ex: c:/>simple_java/src/manifest.txt

We need to mention the main class details.

Manifest-Version: 1.0
Main-Class: com.siva.HelloWorld

Step 4 : Now we need to create the executable jar file with the following command

c:/simple_java/src>jar cvfm simple_java.jar manifest.txt com/siva/*.class

Step 5: Run the executable jar file

c:/simple_java/src>java -jar simple_java.jar

Simple ANT build.xml- which used to compile , run and create the executable jar file which includes manifest file.

Before Starting with build.xml- We need to know What is ANT(Another Neat Tool]. Used for to build the application.

setting the ANT in our system.

Step 1: Down load the latest code from the ANT site .[Prefer to download the .ZIP file]


Download

Step 2: Unzip the Downloaded file, Then set the path.
Setting the Path
Right Click on My Computer ->Properties ->Advanced-> Environment Variables-> System variables -> select Path -> Edit ->give semicolon(;) end of the path value-> paste the ant location upto bin

Ex:
C:\apache-ant-1.8.2-bin\apache-ant-1.8.2\bin

Step 4: Create java programs related to your purpose.
Step 5: create build.xml file, then write the code inside build.xml, for
compilation, creating executable jar file the application.

Step 6: Run the build.xml-> by using the ant command

EX:
c:/simple_javaproject>ant

Down Load Source Code

AddToAny

Contact Form

Name

Email *

Message *