最近需要用ant来生成文件,java类。我才开始了解了这个工具。仔细看了一下,感觉这个小工具的强大功能。

博主也是初学者,在网上收集了资料,尝试了配置:感觉有些高手写得不错变引用之。

配置如下:

  
以上只是最基本的配置。其实在myeclipse中集成了ant。

如图:

  aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAaoAAAB/CAIAAAAxaRGJAAASo0lEQVR4nO2db1AUZ57H503e8yJVWV9cJZfNelQs1wsaV1mD2blK0ORO76zLll5JaQj2xf1TEe6MeoIOuHoDxstEwZgz4BgjN5qgJCaTmY0WslsQclp7EEPgYBOgkDAMMzgCwsDk6rkX3dP9dPfTPYPO3+7vp35ldT/zPN3PWPGT59dPz/NYnE5nvfurdz7pQpg8nACYDIvT6Uz7PzwEAoFIfUB/CATCpCHpjzwAu66PZns8yNcHAGQjCdPfyFQkewP6A8CEpEF/hJDc4pOEkLRbD/oDwMxAf9AfACYlWfrratonBvQHAMhAkqK/zg/30Z92friXt55IMvXXY1tpsbx8BfoDAOiTSP3VVVbXVVbXVdrnxxrmxxpmBk4Guo4Ot1b878eldZV2QsjGAxf4+hr667GttGy9tGDZyZp0HVu+cvVyS8m5hTSE/gAwIQvWX0tLi91uVxTy+qvef+zwWx3k7h/YEbUeSab+2qpXL6/uOfdyzOtAfwCYnYXp79q1a0uWLFm8eLGiXEx+y0pPkPEr7CDkgz/05BafzC0+eeb3XUSpvytbLVFWHmuTlyyv7hHtFi0rOcdo0mNbudrWFRm5VBIt4a+z2lZdQl1K2RD6A8CELEB/vPs2b96so79X/vkdMvK+ZlDEGpFd2WpZbeuSl3cdU2W18tGfZD26+ZWtlujTwK5jy4VyjP4AMDvx6k9035YtW3T098ttDWTgJBk4uW1H/faS+u0lDdtL+IP6bSX123fUb+OPd9RvL6nX09+lEoscatQmek1psXMvS+NE6lhhUugPAEBInPqj3aevvxf+6Tzpq+ZjU9F7Hw39n1b8w9ZzMfQnZa+MahbGII5KaaUEGfoDALCJS392u30xxZEjRxQVRP2t/ceLpLuC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Wnmk5eObMwEBLsm8HAAD6pEh/AwMta1tatrW0XL9+3el8f+2ZFhgQAJBe/h+GGNhMfxJcJgAAAABJRU5ErkJggg==" alt="" />

新建一个java项目,然后在src目录下新建一个build.xml的文件。

运行build.xml,采用ant build运行。呵呵,你的简单目的达成了。

helloWorld.java文件代码如下:

  

 package com.test.ant;

 public class HelloWorld {

     public static void main(String[] args) {
System.out.println("hellow world");
}
}

build.xml 文件代码如下:

  <?xml version="1.0" encoding="UTF-8" ?>
  <project name="HelloWorld" default="run" basedir=".">
  <property name="src" value="build/src" />
  <property name="dest" value="build/classes" />
  <property name="hello_jar" value="hello.jar" />
  <property name="name" value="HelloWorld" />
  <property name="version" value="1.0" />
  <property name="year" value="2010" />
  <echo message="----------- ${name} ${version} [${year}] ------------" />
  <target name="init">
  <echo message="mkdir ${dest}"></echo>
  <mkdir dir="${dest}" />
  </target>
  <target name="compile" depends="init" description="Compile Java code">
  <javac srcdir="${src}" destdir="${dest}" includeantruntime="on"/>
  </target>
  <target name="build" depends="compile">
  <jar jarfile="build/${hello_jar}" basedir="${dest}"/>
  </target>
  <target name="run" depends="build">
  <java classname="test.ant.HelloWorld" classpath="build/${hello_jar}"/>
  </target>
  <target name="clean">
  <delete dir="${dest}" />
  <delete file="${hello_jar}" />
  </target>
  </project>
</project>

在运行程序中,我们可能遇到 Content is not allowed in prolog.的错误。这类问题的解决方法是编码问题,详情参考:http://blog.sina.com.cn/s/blog_6d5d8b580100txon.html

好了,天天学习天天进步,不会就百度,然后自己整理一些!

ant的入门 配置与安装的更多相关文章

  1. webpack新手入门——配置及安装

    webpack 是一个现代 JavaScript 应用程序的静态模块打包器.当 webpack 处理应用程序时,它会递归地构建一个依赖关系图(dependency graph),其中包含应用程序需要的 ...

  2. Ant, JUnit以及Sonar的安装+入门资料

    Ant 感觉是个和Make/Grunt类似的东东,build一个项目用的.安装很容易,跟装JDK类似,就是解压->设环境变量->没了.注意装之前要先确认Java装好了(有点废话). 下载地 ...

  3. Maven&nbsp;3&nbsp;入门&nbsp;--&nbsp;安装与配置

    Maven 3 入门 -- 安装与配置 Maven以及其Eclipse插件m2eclipse的安装 (本文参考了Maven实战) 检查JDK的安装以及环境变量的配置 打开cmd echo %Java_ ...

  4. Linux入门总结——虚拟机安装配置以及vim简单操作

    安装配置ubuntu 安装准备 vittualbox-5.2.22版本(win10) ubuntu-12.04 安装VirtualBox 1.双击VirtualBox-5.2.2-119230-Win ...

  5. Ant快速入门(一)-----Ant介绍

    Ant是一种基于Java的生成工具.从作用上来看,它类似于C编程(UNIX平台上使用比较多)的Make工具,C/C++项目经常使用Make工具来管理整个项目的编译,生成 Make使用Shell命令来定 ...

  6. vim学习、各类插件配置与安装

    vim学习.各类插件配置与安装 vim 插件 配置 1. vim学习 vim基础学习:根据网上流行基础文章<简明Vim练级攻略>,进阶书籍<vim实用技巧>.注:进阶书籍可以在 ...

  7. CEPH集群操作入门--配置

      参考文档:CEPH官网集群操作文档   概述 Ceph存储集群是所有Ceph部署的基础. 基于RADOS,Ceph存储集群由两种类型的守护进程组成:Ceph OSD守护进程(OSD)将数据作为对象 ...

  8. webpack4入门配置

    下面是抄过来的,方便自己翻越 webpack4.x入门配置   1.首先npm install webpack webpack-cli webpack-dev-server -g (mac电脑用超级管 ...

  9. jmeter安装教程与新手入门(附jdk安装教程)

    一.前言 最近要对网站做性能测试,提到了并发数测试,查了下,还是决定使用jmeter来完成这项测试,这里总结了jmeter完整的安装教程,附上新手使用教程. 二.jmeter安装 1.jdk安装(jm ...

随机推荐

  1. 单线多拨,傻瓜式openwrt单线多拨叠加速率教程

    http://bbs.pceva.com.cn/thread-98362-1-1.html

  2. linux中UUID和LABLE

     一.UUID 第一次看到UUID这个东西,是在Ubuntu系统中看到/boot/grub/grub.cfg中对kernel的配置:linux   /boot/vmlinuz-2.6.31-14-ge ...

  3. poj2787 算24

    每次枚举两个数,一个运算符,得到一个运算结果.在重复执行,直到只剩下一个数即可. #include <iostream> #include <cmath> using name ...

  4. hdu 1885 Key Task(bfs+状态压缩)

    Problem Description The Czech Technical University years of its existence . Some of the university b ...

  5. View中取设置了Tag的UILabel

    UILabel *badge = (UILabel *)[self.view viewWithTag:];

  6. Hacker(15)----嗅探原理

    嗅探指窃听网络中流经的数据包,这里的网络一般指用集线器或路由器组建的局域网.通过嗅探并解析数据包,便可知道数据包中的信息,一旦含有账户密码等隐私信息就可能造成个人资金损失. 嗅探数据包无法通过输入命令 ...

  7. zabbix server is not running: the information displayed may not be current

    一.1.关闭selinux及防火墙 2.在/etc/hosts文件里加入ip及对应的主机名. 3.修改配置文件:zabbix.conf.php /opt/data/apache2/htdocs/zab ...

  8. WEB服务器2--IIS架构(转)

    开始之前可以先读:http://www.cnblogs.com/tiantianle/p/5419445.html 原文:http://www.cnblogs.com/arbin98/archive/ ...

  9. 关于Http协议(2)--转载

    原文链接:http://www.cnblogs.com/mcad/ HTTP工作原理图 请求报文 1.请求报文长什么样?  Chrome核心的请求报文 2.报文结构 3.报文头部每个字段的意义 //从 ...

  10. IT定理:摩尔定理,安迪-比尔定理,反摩尔定理

    前两天在网上不经意间搜到了一本吴军的<浪潮之巅>,讲的是现代国际上计算机界的各大公司的兴衰沉浮,包括AT&T公司与IBM等等,把它当作IT历史书看,到现在已经看了一部分了.其中,我 ...