More Tutorials| Bioinformatics| Open Source| Photoshop| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
Ant make directory with relative path 
 

This example illustrates how to make directory, how to compile java file and how to create jar file.

 

Ant make directory with relative path

                         

This example illustrates how to make directory, how to compile java file and how to create jar file. This is a simple program that uses <classpath refid="test.classpath"> to map with the jar file. In this example five targets are used, the first target <target name="clean"> is used to delete the build and the dist directory. The second target <target name="prepare"> is used to create the build and the dist directory. The third target <target name="compile"> is used to compile the java file and copy the class file in build directory. The fourth target <target name="jar"> is used to create the jar file in the dist directory from the name of test.jar. The fifth target <target name="test"> is used to map with the class path by the reference id. The source code of build.xml file is as follows: 

 

 

 

<project name="AntPath" default="test" basedir=".">
  
  <property name="class" value="Test"/>
  
  <path id="test.classpath">    
    <pathelement location="dist/test.jar"/>
  </path>

  <target name="clean">
    <delete dir="build"/>
    <delete dir="dist"/>
  </target>

  <target name="prepare" depends="clean">
    <mkdir dir="build"/>
    <mkdir dir="dist"/>
  </target>
  
  <target name="compile" depends="prepare">    
    <javac destdir="build" debug="on" optimize="on">
      <src path="src"/>
    </javac>
  </target>
  
  <target name="jar" depends="compile">
    <jar jarfile="dist/test.jar">
      <fileset dir="build">
        <include name="test/*.class"/>
      </fileset>
    </jar>
  </target>

  <target name="test" depends="jar">
    <java fork="true" failonerror="no" classname="${class}">
      <classpath refid="test.classpath"/> 
      <arg line=""/>
    </java>
  </target>

</project>


 Source code of Test.java:

class Test{
  public static void main(String args[]){
    System.out.println("RoseIndia Technology Pvt. Ltd.");
  }
}


Run this program on the appropriate path with ant command. The following output will be displayed.



Download Source Code

                         

» View all related tutorials
Related Tags: sql c database xml file url data ui build property user sed password word driver vi name using this element

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.