Learn how to install Ant and compile a simple hello world program.
学习怎样安装Ant和编译一个简单的hello world程序
Ant > Ant Installation
Ant Installation
Ant is free and open source build tool, written in Java, helps in automating the entire build process of a Java development project.
Ant安装
Ant是免费和开源的build工具,用Java编写,有助于Java 项目开发的自动build处理.
- Ant uses XML build files.
- By default, Ant looks for a build file named build.xml.
- The build file contains information about how to build a particular project.
- Each project contains multiple targets like creating directory, compiling source codes.
- Target can depend on other targets.
- Targets contain tasks.
- Behind each task is a Java class that performs the described work
- Ant 用xml build 文件.
- 默认情况下,Ant会找一个名字叫build.xml的文件.
- 这个build文件包含怎样build详细项目有关信息.
- 每个项目包含多个target像创建目录,编译源码.
- target可以依赖其他的target.
- 在每个任务的后面是描述Java class
To install Ant follow the steps given below.
安装Ant步骤如下:
- Download the latest Ant distribution.
- Extract it (my location is E:\apache-ant-1.7.1)
- Set the following system variables
- ANT_HOME =E:\apache-ant-1.7.1
- PATH = %ANT_HOME%\bin
- 下载Ant的最新发布版本
- 解压(我路径是在E:\apache-ant-1.7.1)
- 设置以下系统变量
- ANT_HOME =E:\apache-ant-1.7.1
- PATH = %ANT_HOME%\bin
To make sure the installation is proper, go to command prompt and execute the command "ant - version", you will see the installed ant version.
保证你的安装设置是正确的,道命令行下运行"ant -version",你会看到安装的ant版本信息

In this example you will see how to compile a java program and compress it into a .jar file using Ant build file. The following listing shows the build.xml file.
在这个例子里你会看到怎么样用Ant构建文件编译Java程序和压缩成.jar文件.Following build.xml列表.
<?xml version="1.0" ?>
<project name="Hello World" default="compress">
<target name="compile">
<javac srcdir="."/>
<echo> Compilation Complete! </echo>
</target>
<target name="compress" depends="compile">
<jar destfile="HelloWorld.jar" basedir="." includes="*.class" />
<echo> Building .jar file Complete! </echo>
</target>
</project>
- The <project> element is the root element in Ant build files. The name attribute of the project element indicates the project name. Each project element can contain multiple<target> elements.
- A target represents a single stage in the build process. A build process can have multiple targets. Here we have two targets compile and compress.
- The default attribute of project element indicates the default target to be executed. Here the default target is compress.
- When you see the compress target, it in turn depends on the compile target, that is indicated by the depends attribute. So the compile target will be executed first.
- The compile target has two task elements <javac> and <echo>. The javac task is used to compile the java files. The attribute srcdir="." indicates all the java files in the current directory. Echo task is used to display message on the console.
- The compress target also performs two tasks, first the <jar> element as the name indicates, is used to build the jar file. The attributes destfile="HelloWorld.jar" , basedir="." andincludes="*.class" indicates all the .class files in the current directory should be compressed into HelloWorld.jar file. Later the echo task is used to display the success message on the console.
To run the build.xml file, open the command prompt, go to the example directory, type the command "ant". You will see the following information.
-
在Ant构建文件里<project>元素是根目录.project 的name属性表示project的名字.每个project元素可以包含多个<target>元素
-
在构建处理过程中target代表单一的步骤,一个构建处理过程中可以包含多个<target>元素.这里我们有2个<target> compile和compress
-
compress target也有2个任务,第一<jar>元素就像名字表示的那样,用来构建jar文件.属性destfile="HelloWorld.jar",basedir="."和indcludes="*.class"表示当前目录下的所有.class文件压缩到HelloWorld.jar文件中.下面是echo的任务是显示成功信息在控制台上
运行build.xml文件,打开命令行.到example目录下,敲 "ant" .你会看见如下信息:

You can download the build file here.
Build file :Download
Project :Download
本文源自:
http://www.vaannila.com/ant/ant-tutorial/ant-tutorial.html
分享到:
相关推荐
16.1.Installation of ANT 16.2.What is ANT 16.3.Configuration of ANT 16.4.Usage of ANT 17.Conclusions 18.Epilogue: Technical Background about this Document 19.About the Author
Thanks go out to SER[G]ANT for updating the russion translation files already June 23 2018:Cheat Engine 6.8.1 Released: Apparently 6.8 contained a couple of annoying bugs, so here's an update that ...
scratch少儿编程逻辑思维游戏源码-工厂逃生.zip
房地产 -辉盛阁项目介绍.pptx
少儿编程scratch项目源代码文件案例素材-新拉力赛.zip
scratch少儿编程逻辑思维游戏源码-混乱弹球.zip
scratch少儿编程逻辑思维游戏源码-过马路.zip
少儿编程scratch项目源代码文件案例素材-侠盗地牢冒险.zip
少儿编程scratch项目源代码文件案例素材-我的领土.zip
scratch少儿编程逻辑思维游戏源码-机器人闯关.zip
少儿编程scratch项目源代码文件案例素材-天空中的英雄.zip
少儿编程scratch项目源代码文件案例素材-突击尖峰.zip
“即刻青旅”前景广阔,随着青年旅舍行业快速发展,2030年市场规模预计达650亿。创作旨在为年轻旅行者打造专属平台,填补国内专门青旅预定空白。融合微信小程序、Spring Boot等技术,实现青旅查询预定、订单管理、活动职位查看及社区分享等功能。 后端框架: 基于Java的SpringBoot快速开发框架 借助Mybatis-plus构建ORM模型进行数据库操作 第三方API:高德地图、腾讯地图
少儿编程scratch项目源代码文件案例素材-像素猫3.zip
内容概要:本文是一份详细的10bit 50MHz SAR ADC学习指南,旨在帮助新手掌握从基础理论到实际电路设计的全过程。文中详细介绍了Cadence仿真工具的应用以及SMIC 40nm工艺库的具体使用方法。重点讲解了栅压自举开关、CDAC(电荷再分配模数转换器)、比较器和SAR逻辑等核心模块的设计原理和技术要点。此外,还提供了测试电路的构建方法及其性能评估手段,如INL/DNL曲线绘制。最后提到了更高性能TI ADC的扩展接口,为后续深入研究打下基础。 适合人群:对模拟集成电路设计感兴趣的电子工程专业学生或刚入行的研发人员。 使用场景及目标:适用于希望深入了解SAR ADC架构、提高自身硬件设计能力的学习者;目标是在实践中掌握关键技术和优化技巧,能够独立完成类似项目的开发。 其他说明:文章不仅提供理论知识,还包括大量实用的操作提示和常见错误避免建议,有助于读者快速上手并减少试错成本。
scratch少儿编程逻辑思维游戏源码-防空火力 3D.zip
智慧消防安全与应急管理是现代城市安全管理的重要组成部分,随着城市化进程的加速,传统消防安全管理面临着诸多挑战,如消防安全责任制度落实不到位、消防设施日常管理不足、消防警力不足等。这些问题不仅制约了消防安全管理水平的提升,也给城市的安全运行带来了潜在风险。然而,物联网和智慧城市技术的快速发展为解决这些问题提供了新的思路和方法。智慧消防作为物联网和智慧城市技术结合的创新产物,正在成为社会消防安全管理的新趋势。 智慧消防的核心在于通过技术创新实现消防安全管理的智能化和自动化。其主要应用包括物联网消防安全监管平台、城市消防远程监控系统、智慧消防平台等,这些系统利用先进的技术手段,如GPS、GSM、GIS等,实现了对消防设施的实时监控、智能巡检和精准定位。例如,单兵定位方案通过信标点定位和微惯导加蓝牙辅助定位技术,能够精确掌握消防人员的位置信息,从而提高救援效率和安全性。智慧消防不仅提升了消防设施的管理质量,还优化了社会消防安全管理资源的配置,降低了管理成本。此外,智慧消防的应用还弥补了传统消防安全管理中数据处理方式落后、值班制度执行不彻底等问题,赋予了建筑消防设施智能化、自动化的能力。 尽管智慧消防技术在社会消防安全管理工作中的应用已经展现出巨大的潜力和优势,但目前仍处于实践探索阶段。相关职能部门和研究企业需要加大研究开发力度,进一步完善系统的功能与实效性。智慧消防的发展既面临风险,也充满机遇。当前,社会消防安全管理工作中仍存在制度执行不彻底、消防设施日常维护不到位等问题,而智慧消防理念与技术的应用可以有效弥补这些弊端,提高消防安全管理的自动化与智能化水平。随着智慧城市理念的不断发展和实践,智慧消防将成为推动社会消防安全管理工作与城市化进程同步发展的关键力量。
scratch少儿编程逻辑思维游戏源码-节奏空间.zip
scratch少儿编程逻辑思维游戏源码-黑白色.zip
scratch少儿编程逻辑思维游戏源码-简单射击游戏.zip