Differences

This shows you the differences between two versions of the page.

Link to this comparison view

antbuildhowto [2014/10/26 01:52] (current)
Line 1: Line 1:
 +==== Using Ant to build a Java program/​application ====
 +
 +Howto :
 +
 +  - Create a Directory where you will build and will also contain java src file
 +  - Create all source files (extension = .java)
 +  - Example here uses Hello.java (Simple Hello World program which also dumps command line arguments)
 +
 +<code lang=java>​
 +// Hello.java
 +
 +import java.io.*;
 +
 +public class Hello
 +{
 +   ​public static void main (String[] argv)
 +   {
 +      System.out.print("​Hello world"​);​
 +          if (argv.length > 0)
 +          {
 +                System.out.println("​Argument[0] = "​+argv[0]);​
 +          }
 +   }
 +}
 +</​code>​
 +
 +<code lang=java>​
 +<project default="​compile">​
 +  <target name="​compile">​
 +    <javac srcdir="​."​ />
 +  </​target>​
 +
 +  <target name="​jar"​ depends="​compile">​
 +    <jar destfile="​Hello.jar"​
 +         ​basedir="​."​
 +         ​includes="​**/​*.class"​
 +         />
 +  </​target>​
 +
 +  <target name="​run"​ depends="​jar">​
 +    <java classname="​Hello"​
 +          classpath="​Hello.jar"​
 +          fork="​true"​
 +          />
 +  </​target>​
 +</​project>​
 +</​code>​
 +
 +==== Steps ====
 +
 +  - ant compile
 +  - ant run
 +
 +
 +----
 +[[javainfo|Back to Java]]
 +
 +
 +
 +
  
antbuildhowto.txt ยท Last modified: 2014/10/26 01:52 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0