Ant ultra-simple entry

  Ant is a very powerful tool, can not learn oh; P 

  An ultra-simple example: 

  Goals: ant type tools to complete a java compiler and want to run to see the results, and suggested that completion of the process. 

  Process: 

  1, download ant: http://ant.apache.org site to download the latest version of ant1.6.2, apache-ant-1.6.2-bin.zip unzipping to the d: \ directory ant 

  2, setting up the environment variables: 
  Ant_home = d: \ ant 
  Java_home = D: \ Borland \ JBuilderX \ jdk1.4 
  Path =% path%% java_hme% \ bin;% ant_home% \ bin 

  3, the preparation of java categories: 
  Public class Test 
  ( 
  Public static void main (String [] arg) 
  ( 
  System.out.println ( "Hello Ant !!"); 
  ) 
  ) 
  Save As Test.java 

  4, document preparation build.xml: 
  <project Basedir="." default="compile" name="TestANT"> 
  <target Name="compile"> 
  <echo Message="ant Start!" /> 
  <javac Destdir="." srcdir="." /> 
  <java Classpath="." classname="Test" /> 
  <echo Message="ant end!" /> 
  </ Target> 
  </ Project> 
  And the build.xml Test.java documents into e: \ test \ directory 

  5. 

  6, running ant: 
  Entered in the dos command window 
  Cd e: \ test 
  E: 
  Ant 
  Output: 
  E: \ test> ant 
  Buildfile: build.xml 

  Compile: 
  [Echo] ant Start! 
  [Java] Hello Ant! 
  [Echo] ant end! 

  BUILD SUCCESSFUL 
  Total time: 2 seconds 
  E: \ test> 

  Note: 
  1, as far as possible, not to ant_home directory containing '-' symbols, I unpack into default apache-ant-1.6.2-bin directory, there will be problems 
  2, detailed information can be reference ant \ docs \ directory under the file 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • DZone
  • Netvouz
  • Propeller

Tags:

Releated Java Articles

Comments

Leave a Reply