Ant compile-run-package-delete Basic Java project

Source: Internet
Author: User

  1. The JDK installation configuration is checked online, and the configuration is similar to the JDK.

  2. Ant basic knowledge of learning https://www.w3cschool.cn/ant/4xdp1hw8.html

  3. Project Files Directory


    650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M00/06/0C/wKiom1mwt7GSHc4ZAAAm_xTEhTQ263.png-wh_500x0-wm_ 3-wmp_4-s_3583460867.png "style=" Float:none; "title=" 1.png "alt=" Wkiom1mwt7gshc4zaaam_xtehtq263.png-wh_50 "/>

    650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/A4/BD/wKioL1mwt5Kj_8DOAAAjL_ofpKs152.png-wh_500x0-wm_ 3-wmp_4-s_1813503455.png "style=" Float:none; "title=" ~k9m72tg5dug@bt$cpk7w58.png "alt=" wKioL1mwt5Kj_8DOAAAjL_ Ofpks152.png-wh_50 "/>

  4. <?xml version= "1.0"  encoding= "UTF-8"? ><project name= "Test"  default= "Run-Test"  basedir= "." ><property name= "src"  value= "src"/><property name= "Lib"  value= "Build/lib"/> <property name= "Dest"  value= "build/classes"/><property name= "Np_jar"  value= "build /lib/test.jar "/><!--  Create Build/classes folder and Build/lib folder under Project base directory  --><target name=" Create-path "><mkdir dir=" ${dest} "/><mkdir dir=" ${lib} "/></target><!--  Compile the SRC source code file under the project base directory into a class file under the Build/classes folder  --><target name= "Create-class" ><javac  srcdir= "${src}"  destdir= "${dest}"/></target><!--  build/ Classes class files packaged as jars in Build/lib/test.jar  --><target name= "Create-jar" ><jar  Destfile= "${np_jar}"  basedir= "${dest}" ><manifest><attribute name= "Main-Class"  value = "Test"/></manifest></jar></target><!--  Run the test class in the Build/lib/test.jar file  --><target name= "Run-test" >< Java classname= "Test"  classpath= "${np_jar}"/></target><!--  Delete files and folders  -->< Target name= "clean" ><delete file= "${np_jar}"/><delete dir= "${dest}"/><delete  dir= "${lib}"/></target></project>
  5. Run the ANT:WIN10 system, under the project base directory, hold down SHIFT, right-click in the space, and select "Open Power-shell window Here"

    Create a folder in turn: Ant Create-path

    Compiling source code: Ant Create-class

    Package the compiled source code into jar:ant Create-jar

    Run the class with the main method in the jar file: Ant run-test

    Delete files: Ant clean

  6. Learn well!

This article from the "12571026" blog, reproduced please contact the author!

Ant compile-run-package-delete Basic Java project

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.