﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>语源科技BlogJava-pixysoft</title><link>http://www.blogjava.net/pixysoft/</link><description /><language>zh-cn</language><lastBuildDate>Tue, 28 Apr 2026 18:56:02 GMT</lastBuildDate><pubDate>Tue, 28 Apr 2026 18:56:02 GMT</pubDate><ttl>60</ttl><item><title>AMF 学习笔记</title><link>http://www.blogjava.net/pixysoft/archive/2010/06/17/323706.html</link><dc:creator>张辰</dc:creator><author>张辰</author><pubDate>Thu, 17 Jun 2010 06:15:00 GMT</pubDate><guid>http://www.blogjava.net/pixysoft/archive/2010/06/17/323706.html</guid><wfw:comment>http://www.blogjava.net/pixysoft/comments/323706.html</wfw:comment><comments>http://www.blogjava.net/pixysoft/archive/2010/06/17/323706.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/pixysoft/comments/commentRss/323706.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/pixysoft/services/trackbacks/323706.html</trackback:ping><description><![CDATA[<div>Flash 与后台交互方式包括了：</div>
<div>1. LoadVars(xml) 实际上就是flash里面一个对象，类似一个连接器。新建之后，通过sendAndLoad获取、设置值。和httpposter一样<br />
<span style="border-collapse: collapse; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px; ">var data_lv = new LoadVars();</span><span style="border-collapse: collapse; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px; ">&nbsp;</span></div>
<div>2. <strong>flash remoting. flash需要安装components；后台服务器需要OpenAMF。<br />
</strong><span style="border-collapse: collapse; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px; ">gateway_conn = NetServices.createGatewayConnection();&nbsp;</span><span style="border-collapse: collapse; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px; ">myService = gateway_conn.getService("myservice", this);</span><span style="border-collapse: collapse; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px; ">&nbsp;</span></div>
<div>3. webservice 也是在flash里面初始化一个ws的对象，然后调用。<span style="border-collapse: collapse; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 25px; ">var ws:WebService = new WebService(ws_url);</span></div>
<div>4. XMLSocket 主要是即时通讯&nbsp;<span style="border-collapse: collapse; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 25px; ">var socket:XMLSocket = new XMLSocket();</span></div>
<div><span style="border-collapse: collapse; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 25px; ">5. 直接开flash的socket</span></div>
<div><span style="border-collapse: collapse; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; line-height: 25px; "><a href="http://androider.javaeye.com/blog/268933">http://androider.javaeye.com/blog/268933</a><br />
在一个AMF交互的例子中，服务器建立一个MAP对象，例如：<br />
<div>&nbsp;&nbsp; HashMap map=new HashMap(); &nbsp;</div>
<div>&nbsp;&nbsp; map.put("Event", "人物移动"); &nbsp;</div>
<div>&nbsp;&nbsp; map.put("user", "闪刀浪子"); &nbsp;</div>
<div>&nbsp;&nbsp; map.put("x", 100); &nbsp;</div>
<div>&nbsp;&nbsp; map.put("y", 100); &nbsp; &nbsp;</div>
<div>这样flash就可以获取这个对象：<span  style="border-collapse: separate; font-family: Monaco, 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Consolas, 'Courier New', monospace; line-height: 18px; font-size: 12px; ">var&nbsp;obj:Object=<span class="keyword" style="color: #7f0055; font-weight: bold; ">new</span><span style="color: black; ">&nbsp;Object(); &nbsp;</span></span></div>
</span></div>
<img src ="http://www.blogjava.net/pixysoft/aggbug/323706.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pixysoft/" target="_blank">张辰</a> 2010-06-17 14:15 <a href="http://www.blogjava.net/pixysoft/archive/2010/06/17/323706.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Spring 技术小结</title><link>http://www.blogjava.net/pixysoft/archive/2010/06/17/323681.html</link><dc:creator>张辰</dc:creator><author>张辰</author><pubDate>Thu, 17 Jun 2010 01:33:00 GMT</pubDate><guid>http://www.blogjava.net/pixysoft/archive/2010/06/17/323681.html</guid><wfw:comment>http://www.blogjava.net/pixysoft/comments/323681.html</wfw:comment><comments>http://www.blogjava.net/pixysoft/archive/2010/06/17/323681.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.blogjava.net/pixysoft/comments/commentRss/323681.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/pixysoft/services/trackbacks/323681.html</trackback:ping><description><![CDATA[<p><br />
<strong>1. Spring IoC容器的意义<br />
</strong><br />
使用BeanFactory，根据制定的xml，&nbsp;动态生成对象然后加载。<br />
<br />
<span style="color: red">只要是从BeanFactory获取的对象，都会根据xml进行装配。</span><br />
<br />
<br />
<strong>2. Spring MVC<br />
</strong><br />
在web.xml配置了DispatcherServlet，让所有请求都被这个servlet拦截。同时配置了这个servlet的初始化对象。<br />
。init-param = /WEB-INF/Config.xml -&gt;<br />
。viewResolver：：org.springframework.web.servlet.view.InternalResourceViewResolver<br />
。urlMapping：：org.springframework.web.servlet.handler.SimpleUrlHandlerMapping<br />
<br />
这个urlMapping的目标，可能是被spring接管的对象，例如<strong>SimpleFormController</strong><br />
<br />
<span style="color: red">当配置了DispactcherServlet之后，通过设置合适的初始化对象，能够实现某种MVC模式。</span><br />
<br />
<br />
<br />
3. spring + blazeds <strong>集成<br />
</strong><a href="http://static.springsource.org/spring-flex/docs/1.0.x/reference/html/ch02s02.html">http://static.springsource.org/spring-flex/docs/1.0.x/reference/html/ch02s02.html</a><br />
<br />
在web.xml配置了2个dispatcherservlet<br />
。*.service === /WEB-INF/remoting-servlet.xml<br />
。/messagebroker/* === /WEB-INF/flex-config.xml 表示把blazeds的请求映射到messagebroker<br />
<br />
<br />
。第一个servlet继续配置了urlMapping <br />
==<span class="Apple-style-span" style="word-spacing: 0px; font: medium Simsun; text-transform: none; color: rgb(0,0,0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2; webkit-border-horizontal-spacing: 0px; webkit-border-vertical-spacing: 0px; webkit-text-decorations-in-effect: none; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px"><span class="Apple-style-span" style="font-size: 14px; text-indent: 28px; line-height: 22px; font-family: ����, ������, tahoma, verdana, arial, sans-serif; text-align: left"><span lang="EN-US" style="vertical-align: middle">HessianServiceExporter</span><span style="vertical-align: middle; font-family: 宋体">可将一个普通</span><span lang="EN-US" style="vertical-align: middle">bean</span><span style="vertical-align: middle; font-family: 宋体">导出成远程服务 这样这些被映射出来的service可以通过url访问。</span></span></span><br />
<span style="color: red">问题：这些service有固定的方法，比如execute，那么这些方法如何被调用了？代码上看，是被command调用了。<br />
</span>回答：见第二个配置<br />
<br />
。第二个servlet同样配置了urlMapping；还包括<br />
..<font face="Arial">MessageBrokerHandlerAdapter<br />
</font>..<font face="Arial">RemotingDestinationExporter -&gt; <font face="Arial">callDisptacherService</font> -&gt; <font face="Arial">CallDispatcher</font> -&gt; Command.execute<br />
</font><span style="color: red">问题：那么CallDispatcher的Call是如何调用的？<br />
</span>回答：在Flash的xml文件里面指定调用了。<br />
<br />
</p>
<div title="Print Page Break" style="font-size: 1px; page-break-before: always; vertical-align: middle; height: 1px; background-color: #c0c0c0">&nbsp; </div>
<p><br />
这样故事就全部被串起来了。<br />
<br />
首先blazeds是个servlet，被封装过后，能够解析flash传输的amf格式。<br />
<br />
通过spring的配置，flash的请求被转移到了messagebroker = blazeds，同时这个messagebroker依赖了特定的bean，例如callHandler. 这些handler又依赖了service 的属性，这个属性就是我可以控制的，同时被flash调用的。<br />
<br />
例如<br />
</p>
<div title="Print Page Break" style="font-size: 1px; page-break-before: always; vertical-align: middle; height: 1px; background-color: #c0c0c0">&nbsp; </div>
<p><br />
<br />
<strong>what is&nbsp;web.xml :: listener&nbsp;<br />
</strong> 它能捕捉到服务器的启动和停止! 在启动和停止触发里面的方法做相应的操作!<br />
一定是httpServlet<br />
<a href="http://zhidao.baidu.com/question/39980900">http://zhidao.baidu.com/question/39980900</a><br />
<br />
<br />
<strong>如何加载services-config.xml</strong></p>
<span class="Apple-style-span" style="word-spacing: 0px; font: medium Simsun; text-transform: none; color: rgb(0,0,0); text-indent: 0px; white-space: normal; letter-spacing: normal; border-collapse: separate; orphans: 2; widows: 2; webkit-border-horizontal-spacing: 0px; webkit-border-vertical-spacing: 0px; webkit-text-decorations-in-effect: none; webkit-text-size-adjust: auto; webkit-text-stroke-width: 0px"><span class="Apple-style-span" style="font-size: 12px; line-height: 18px; font-family: Arial, sans-serif, Helvetica, Tahoma; text-align: left">MessageBrokerFactoryBean将会去寻找BlazeDS的配置文件(默认位置为/WEB-INF/flex/services-config.xml)</span></span>
<img src ="http://www.blogjava.net/pixysoft/aggbug/323681.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pixysoft/" target="_blank">张辰</a> 2010-06-17 09:33 <a href="http://www.blogjava.net/pixysoft/archive/2010/06/17/323681.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oops! Spring Quick Start</title><link>http://www.blogjava.net/pixysoft/archive/2010/06/16/323666.html</link><dc:creator>张辰</dc:creator><author>张辰</author><pubDate>Wed, 16 Jun 2010 12:13:00 GMT</pubDate><guid>http://www.blogjava.net/pixysoft/archive/2010/06/16/323666.html</guid><wfw:comment>http://www.blogjava.net/pixysoft/comments/323666.html</wfw:comment><comments>http://www.blogjava.net/pixysoft/archive/2010/06/16/323666.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/pixysoft/comments/commentRss/323666.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/pixysoft/services/trackbacks/323666.html</trackback:ping><description><![CDATA[<br />
本文讲解一个不规范的spring quick start.<br />
<br />
1. 下载spring的插件包，什么版本之类的不用管了。反正能用。<br />
spring.jar&nbsp;<a href="http://www.boxcn.net/shared/yg306zac1h">http://www.boxcn.net/shared/yg306zac1h</a><br />
common-logging.jar&nbsp;<a href="http://www.boxcn.net/shared/ix93ziqljv">http://www.boxcn.net/shared/ix93ziqljv</a><br />
<br />
2. 进入eclipse，File - New - Java Project.<br />
projectname = spring001 ===&gt; Next<br />
在新建导向的第二页，是Java Settings, 选择Libraries -&gt; Add External JARS -&gt; 添加上面2个jar<br />
finish<br />
<br />
3. 进入Package Explorer, 在src下新建一个class.<br />
<strong>Package</strong> = com.java114.spring.test<br />
<strong>Name</strong> = HelloWordSpring<br />
再复选框：public static void main(String[] args) 钩上<br />
<br />
4. 在HelloWordSpring.java 输入以下的代码<br />
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #0000ff">package</span><span style="color: #000000">&nbsp;com.java114.spring.test;<br />
<br />
</span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;org.springframework.beans.factory.BeanFactory;<br />
</span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;org.springframework.beans.factory.xml.XmlBeanFactory;<br />
</span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;org.springframework.core.io.ClassPathResource;<br />
</span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;org.springframework.core.io.Resource;<br />
<br />
</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">class</span><span style="color: #000000">&nbsp;HelloWordSpring<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">private</span><span style="color: #000000">&nbsp;String&nbsp;msg;<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;setMsg(String&nbsp;msg)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">this</span><span style="color: #000000">.msg&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;msg;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;sayHello()<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(msg);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">static</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;main(String[]&nbsp;args)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Resource&nbsp;res&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">new</span><span style="color: #000000">&nbsp;ClassPathResource(</span><span style="color: #000000">"</span><span style="color: #000000">com/java114/spring/test/bean.xml</span><span style="color: #000000">"</span><span style="color: #000000">);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BeanFactory&nbsp;factory&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">new</span><span style="color: #000000">&nbsp;XmlBeanFactory(res);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;HelloWordSpring&nbsp;hello&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(HelloWordSpring)&nbsp;factory.getBean(</span><span style="color: #000000">"</span><span style="color: #000000">helloBean</span><span style="color: #000000">"</span><span style="color: #000000">);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hello.sayHello();<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
<br />
}<br />
</span></div>
<br />
5. 在和HelloWordSpring.java 相同目录下面，再新建一个xml文件，名字是bean.xml, 内容如下<br />
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #0000ff">&lt;?</span><span style="color: #ff00ff">xml&nbsp;version="1.0"&nbsp;encoding="UTF-8"</span><span style="color: #0000ff">?&gt;</span><span style="color: #000000"><br />
</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">beans&nbsp;</span><span style="color: #ff0000">xmlns</span><span style="color: #0000ff">="http://www.springframework.org/schema/beans"</span><span style="color: #ff0000">&nbsp;xmlns:xsi</span><span style="color: #0000ff">="http://www.w3.org/2001/XMLSchema-instance"</span><span style="color: #ff0000">&nbsp;xmlns:aop</span><span style="color: #0000ff">="http://www.springframework.org/schema/aop"</span><span style="color: #ff0000">&nbsp;xmlns:tx</span><span style="color: #0000ff">="http://www.springframework.org/schema/tx"</span><span style="color: #ff0000">&nbsp;xsi:schemaLocation</span><span style="color: #0000ff">="http://www.springframework.org/schema/beans&nbsp;http://www.springframework.org/schema/beans/spring-beans-2.0.xsd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http://www.springframework.org/schema/aop&nbsp;http://www.springframework.org/schema/aop/spring-aop-2.0.xsd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http://www.springframework.org/schema/tx&nbsp;http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">bean&nbsp;</span><span style="color: #ff0000">id</span><span style="color: #0000ff">="helloBean"</span><span style="color: #ff0000">&nbsp;class</span><span style="color: #0000ff">="com.java114.spring.test.HelloWordSpring"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="msg"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="simple&nbsp;spring&nbsp;demo"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">bean</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">beans</span><span style="color: #0000ff">&gt;</span></div>
为什么这样写，我也不知道，不管他。<br />
<br />
6. 鼠标右键选择HelloWordSpring.java, 选择Run As - Java Applications， 得到结果：<br />
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #000000">2010-6-16&nbsp;21:39:47&nbsp;org.springframework.beans.factory.xml.XmlBeanDefinitionReader&nbsp;loadBeanDefinitions<br />
信息:&nbsp;Loading&nbsp;XML&nbsp;bean&nbsp;definitions&nbsp;from&nbsp;class&nbsp;path&nbsp;resource&nbsp;[com/java114/spring/test/bean.xml]<br />
simple&nbsp;spring&nbsp;demo<br />
</span></div>
<br />
 <img src ="http://www.blogjava.net/pixysoft/aggbug/323666.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pixysoft/" target="_blank">张辰</a> 2010-06-16 20:13 <a href="http://www.blogjava.net/pixysoft/archive/2010/06/16/323666.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oops! Axis quick start ! part 3 -- stub</title><link>http://www.blogjava.net/pixysoft/archive/2008/12/18/247046.html</link><dc:creator>张辰</dc:creator><author>张辰</author><pubDate>Thu, 18 Dec 2008 03:03:00 GMT</pubDate><guid>http://www.blogjava.net/pixysoft/archive/2008/12/18/247046.html</guid><wfw:comment>http://www.blogjava.net/pixysoft/comments/247046.html</wfw:comment><comments>http://www.blogjava.net/pixysoft/archive/2008/12/18/247046.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/pixysoft/comments/commentRss/247046.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/pixysoft/services/trackbacks/247046.html</trackback:ping><description><![CDATA[比较难的一部分<br />
<br />
前提条件：<br />
axis安装路径 C:\ericsson\javaextend\axis-1_4<br />
项目名称：axisdemo<br />
已经有的类：com.service.myService.java<br />
配置文件：server-config.wsdd<br />
<br />
1. 在项目添加java2wsdl目录<br />
<br />
2.目录下面添加build.xml文件<br />
<div style="border-right: rgb(204,204,204) 1px solid; padding-right: 5px; border-top: rgb(204,204,204) 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: rgb(204,204,204) 1px solid; width: 98%; padding-top: 4px; border-bottom: rgb(204,204,204) 1px solid; background-color: rgb(238,238,238)"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0,0,255)">&lt;?</span><span style="color: rgb(255,0,255)">xml&nbsp;version="1.0"&nbsp;encoding="UTF-8"</span><span style="color: rgb(0,0,255)">?&gt;</span><span style="color: rgb(0,0,0)"><br />
</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">project&nbsp;</span><span style="color: rgb(255,0,0)">name</span><span style="color: rgb(0,0,255)">="Generate&nbsp;WSDL&nbsp;from&nbsp;JavaBeans&nbsp;as&nbsp;Web&nbsp;Services"</span><span style="color: rgb(255,0,0)">&nbsp;default</span><span style="color: rgb(0,0,255)">="j2w-all"</span><span style="color: rgb(255,0,0)">&nbsp;basedir</span><span style="color: rgb(0,0,255)">="."</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">property&nbsp;</span><span style="color: rgb(255,0,0)">name</span><span style="color: rgb(0,0,255)">="build.dir"</span><span style="color: rgb(255,0,0)">&nbsp;value</span><span style="color: rgb(0,0,255)">="../build/classes"</span><span style="color: rgb(255,0,0)">&nbsp;</span><span style="color: rgb(0,0,255)">/&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">property&nbsp;</span><span style="color: rgb(255,0,0)">name</span><span style="color: rgb(0,0,255)">="axis.dir"</span><span style="color: rgb(255,0,0)">&nbsp;location</span><span style="color: rgb(0,0,255)">="C:\ericsson\javaextend\axis-1_4"</span><span style="color: rgb(255,0,0)">&nbsp;</span><span style="color: rgb(0,0,255)">/&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">path&nbsp;</span><span style="color: rgb(255,0,0)">id</span><span style="color: rgb(0,0,255)">="classpath.id"</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">fileset&nbsp;</span><span style="color: rgb(255,0,0)">dir</span><span style="color: rgb(0,0,255)">="${axis.dir}/lib"</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">include&nbsp;</span><span style="color: rgb(255,0,0)">name</span><span style="color: rgb(0,0,255)">="*.jar"</span><span style="color: rgb(255,0,0)">&nbsp;</span><span style="color: rgb(0,0,255)">/&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(128,0,0)">fileset</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">pathelement&nbsp;</span><span style="color: rgb(255,0,0)">location</span><span style="color: rgb(0,0,255)">="${build.dir}"</span><span style="color: rgb(255,0,0)">&nbsp;</span><span style="color: rgb(0,0,255)">/&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(128,0,0)">path</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">taskdef&nbsp;</span><span style="color: rgb(255,0,0)">name</span><span style="color: rgb(0,0,255)">="axis-java2wsdl"</span><span style="color: rgb(255,0,0)">&nbsp;classname</span><span style="color: rgb(0,0,255)">="org.apache.axis.tools.ant.wsdl.Java2WsdlAntTask"</span><span style="color: rgb(255,0,0)">&nbsp;loaderref</span><span style="color: rgb(0,0,255)">="axis"</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">classpath&nbsp;</span><span style="color: rgb(255,0,0)">refid</span><span style="color: rgb(0,0,255)">="classpath.id"</span><span style="color: rgb(255,0,0)">&nbsp;</span><span style="color: rgb(0,0,255)">/&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(128,0,0)">taskdef</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">target&nbsp;</span><span style="color: rgb(255,0,0)">name</span><span style="color: rgb(0,0,255)">="j2w-all"</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">antcall&nbsp;</span><span style="color: rgb(255,0,0)">target</span><span style="color: rgb(0,0,255)">="j2w-JavaBeanWS"</span><span style="color: rgb(255,0,0)">&nbsp;</span><span style="color: rgb(0,0,255)">/&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(128,0,0)">target</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">target&nbsp;</span><span style="color: rgb(255,0,0)">name</span><span style="color: rgb(0,0,255)">="j2w-JavaBeanWS"</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">axis-java2wsdl&nbsp;</span><span style="color: rgb(255,0,0)">classname</span><span style="color: rgb(0,0,255)">="com.service.myService"</span><span style="color: rgb(255,0,0)">&nbsp;classpath</span><span style="color: rgb(0,0,255)">="${build.dir}"</span><span style="color: rgb(255,0,0)">&nbsp;methods</span><span style="color: rgb(0,0,255)">="getusername"</span><span style="color: rgb(255,0,0)">&nbsp;output</span><span style="color: rgb(0,0,255)">="myService.wsdl"</span><span style="color: rgb(255,0,0)">&nbsp;location</span><span style="color: rgb(0,0,255)">="http://localhost:8080/axisdemo/services/myService"</span><span style="color: rgb(255,0,0)">&nbsp;namespace</span><span style="color: rgb(0,0,255)">="http://localhost:8080/axisdemo/services/myService"</span><span style="color: rgb(255,0,0)">&nbsp;namespaceImpl</span><span style="color: rgb(0,0,255)">="http://localhost:8080/axisdemo/services/myService"</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(128,0,0)">axis-java2wsdl</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(128,0,0)">target</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
</span><span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(128,0,0)">project</span><span style="color: rgb(0,0,255)">&gt;</span></div>
注意：build.dir / axis.dir / j2w-javabeanws几个地方的内容要修改。<br />
<br />
3. 右键点击build.xml，运行ant，就可以看到生成了myService.wsdl<br />
<br />
4.现在要把这个wsdl转化成为java，新建目录：wsdl2java<br />
<br />
5. 新建一个build.xml，内容：<br />
<div style="border-right: rgb(204,204,204) 1px solid; padding-right: 5px; border-top: rgb(204,204,204) 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: rgb(204,204,204) 1px solid; width: 98%; padding-top: 4px; border-bottom: rgb(204,204,204) 1px solid; background-color: rgb(238,238,238)"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0,0,255)">&lt;?</span><span style="color: rgb(255,0,255)">xml&nbsp;version="1.0"&nbsp;encoding="UTF-8"</span><span style="color: rgb(0,0,255)">?&gt;</span><span style="color: rgb(0,0,0)"><br />
</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">project&nbsp;</span><span style="color: rgb(255,0,0)">name</span><span style="color: rgb(0,0,255)">="wsclient"</span><span style="color: rgb(255,0,0)">&nbsp;default</span><span style="color: rgb(0,0,255)">="all"</span><span style="color: rgb(255,0,0)">&nbsp;basedir</span><span style="color: rgb(0,0,255)">="."</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">property&nbsp;</span><span style="color: rgb(255,0,0)">name</span><span style="color: rgb(0,0,255)">="axis.home"</span><span style="color: rgb(255,0,0)">&nbsp;location</span><span style="color: rgb(0,0,255)">="C:\ericsson\javaextend\axis-1_4"</span><span style="color: rgb(255,0,0)">&nbsp;</span><span style="color: rgb(0,0,255)">/&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">property&nbsp;</span><span style="color: rgb(255,0,0)">name</span><span style="color: rgb(0,0,255)">="options.output"</span><span style="color: rgb(255,0,0)">&nbsp;location</span><span style="color: rgb(0,0,255)">="../wsdl2java"</span><span style="color: rgb(255,0,0)">&nbsp;</span><span style="color: rgb(0,0,255)">/&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">path&nbsp;</span><span style="color: rgb(255,0,0)">id</span><span style="color: rgb(0,0,255)">="axis.classpath"</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">fileset&nbsp;</span><span style="color: rgb(255,0,0)">dir</span><span style="color: rgb(0,0,255)">="${axis.home}/lib"</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">include&nbsp;</span><span style="color: rgb(255,0,0)">name</span><span style="color: rgb(0,0,255)">="**/*.jar"</span><span style="color: rgb(255,0,0)">&nbsp;</span><span style="color: rgb(0,0,255)">/&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(128,0,0)">fileset</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(128,0,0)">path</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">taskdef&nbsp;</span><span style="color: rgb(255,0,0)">resource</span><span style="color: rgb(0,0,255)">="axis-tasks.properties"</span><span style="color: rgb(255,0,0)">&nbsp;classpathref</span><span style="color: rgb(0,0,255)">="axis.classpath"</span><span style="color: rgb(255,0,0)">&nbsp;</span><span style="color: rgb(0,0,255)">/&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">target&nbsp;</span><span style="color: rgb(255,0,0)">name</span><span style="color: rgb(0,0,255)">="-WSDL2Axis"</span><span style="color: rgb(255,0,0)">&nbsp;depends</span><span style="color: rgb(0,0,255)">="init"</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">mkdir&nbsp;</span><span style="color: rgb(255,0,0)">dir</span><span style="color: rgb(0,0,255)">="${options.output}"</span><span style="color: rgb(255,0,0)">&nbsp;</span><span style="color: rgb(0,0,255)">/&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">axis-wsdl2java&nbsp;</span><span style="color: rgb(255,0,0)">output</span><span style="color: rgb(0,0,255)">="${options.output}"</span><span style="color: rgb(255,0,0)">&nbsp;url</span><span style="color: rgb(0,0,255)">="${options.WSDL-URI}"</span><span style="color: rgb(255,0,0)">&nbsp;verbose</span><span style="color: rgb(0,0,255)">="true"</span><span style="color: rgb(255,0,0)">&nbsp;</span><span style="color: rgb(0,0,255)">/&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(128,0,0)">target</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">target&nbsp;</span><span style="color: rgb(255,0,0)">name</span><span style="color: rgb(0,0,255)">="init"</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">echo</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)">Warning:&nbsp;please&nbsp;update&nbsp;the&nbsp;associated&nbsp;WSDL&nbsp;file(s)&nbsp;in&nbsp;the&nbsp;folder&nbsp;wsdl&nbsp;before&nbsp;running&nbsp;the&nbsp;target!</span><span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(128,0,0)">echo</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">echo</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)">Warning:&nbsp;Just&nbsp;run&nbsp;the&nbsp;target(s)&nbsp;related&nbsp;with&nbsp;your&nbsp;developing&nbsp;work!</span><span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(128,0,0)">echo</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">echo</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(128,0,0)">echo</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(128,0,0)">target</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">target&nbsp;</span><span style="color: rgb(255,0,0)">name</span><span style="color: rgb(0,0,255)">="all"</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">antcall&nbsp;</span><span style="color: rgb(255,0,0)">target</span><span style="color: rgb(0,0,255)">="myService"</span><span style="color: rgb(255,0,0)">&nbsp;</span><span style="color: rgb(0,0,255)">/&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(128,0,0)">target</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">target&nbsp;</span><span style="color: rgb(255,0,0)">name</span><span style="color: rgb(0,0,255)">="myService"</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">antcall&nbsp;</span><span style="color: rgb(255,0,0)">target</span><span style="color: rgb(0,0,255)">="-WSDL2Axis"</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;</span><span style="color: rgb(128,0,0)">param&nbsp;</span><span style="color: rgb(255,0,0)">name</span><span style="color: rgb(0,0,255)">="options.WSDL-URI"</span><span style="color: rgb(255,0,0)">&nbsp;location</span><span style="color: rgb(0,0,255)">="../java2wsdl/myService.wsdl"</span><span style="color: rgb(255,0,0)">&nbsp;</span><span style="color: rgb(0,0,255)">/&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(128,0,0)">antcall</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(128,0,0)">target</span><span style="color: rgb(0,0,255)">&gt;</span><span style="color: rgb(0,0,0)"><br />
</span><span style="color: rgb(0,0,255)">&lt;/</span><span style="color: rgb(128,0,0)">project</span><span style="color: rgb(0,0,255)">&gt;</span></div>
注意修改的地方：axis.home<br />
<br />
6.build ant，在wsdl2java目录下面多出来了4个类：<br />
myService.java<br />
MyServiceService.java<br />
myServiceServiceLocator.java<br />
MyServiceSoapBindingStub.java<br />
全部拷贝到src目录下面<br />
<br />
7.在src目录下面添加类：<br />
<div style="border-right: rgb(204,204,204) 1px solid; padding-right: 5px; border-top: rgb(204,204,204) 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: rgb(204,204,204) 1px solid; width: 98%; padding-top: 4px; border-bottom: rgb(204,204,204) 1px solid; background-color: rgb(238,238,238)"><!--<br />
<br />
Code highlighting produced by Actipro CodeHighlighter (freeware)<br />
http://www.CodeHighlighter.com/<br />
<br />
--><span style="color: rgb(0,0,255)">package</span><span style="color: rgb(0,0,0)">&nbsp;com.axistest;<br />
<br />
</span><span style="color: rgb(0,0,255)">import</span><span style="color: rgb(0,0,0)">&nbsp;localhost.axisdemo.services.myService.MyService;<br />
</span><span style="color: rgb(0,0,255)">import</span><span style="color: rgb(0,0,0)">&nbsp;localhost.axisdemo.services.myService.MyServiceServiceLocator;<br />
<br />
</span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)">&nbsp;</span><span style="color: rgb(0,0,255)">class</span><span style="color: rgb(0,0,0)">&nbsp;myServiceTestorByStubs<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: rgb(0,0,255)">public</span><span style="color: rgb(0,0,0)">&nbsp;</span><span style="color: rgb(0,0,255)">static</span><span style="color: rgb(0,0,0)">&nbsp;</span><span style="color: rgb(0,0,255)">void</span><span style="color: rgb(0,0,0)">&nbsp;main(String[]&nbsp;args)&nbsp;</span><span style="color: rgb(0,0,255)">throws</span><span style="color: rgb(0,0,0)">&nbsp;Exception<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyServiceServiceLocator&nbsp;Service&nbsp;</span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)">&nbsp;</span><span style="color: rgb(0,0,255)">new</span><span style="color: rgb(0,0,0)">&nbsp;MyServiceServiceLocator();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MyService&nbsp;port&nbsp;</span><span style="color: rgb(0,0,0)">=</span><span style="color: rgb(0,0,0)">&nbsp;Service.getmyService();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;response&nbsp;</span><span style="color: rgb(0,0,0)"  gt;="</span" &><span style="color: rgb(0,0,0)">&nbsp; port.getusername(</span><span style="color: rgb(0,0,0)"  & span gt;?<><span style="color: rgb(0,0,0)">邹萍</span& style="color: rgb(0,0,0)"  gt;<span>"</span><span style="color: rgb(0,0,0)">);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(response);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}</span></div>
<br />
8.最后运行java application就完成了<br />
<br />
<br />
</span></span>
<img src ="http://www.blogjava.net/pixysoft/aggbug/247046.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pixysoft/" target="_blank">张辰</a> 2008-12-18 11:03 <a href="http://www.blogjava.net/pixysoft/archive/2008/12/18/247046.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oops! Axis quick start ! part 2 -- wsdd</title><link>http://www.blogjava.net/pixysoft/archive/2008/12/17/246851.html</link><dc:creator>张辰</dc:creator><author>张辰</author><pubDate>Wed, 17 Dec 2008 05:51:00 GMT</pubDate><guid>http://www.blogjava.net/pixysoft/archive/2008/12/17/246851.html</guid><wfw:comment>http://www.blogjava.net/pixysoft/comments/246851.html</wfw:comment><comments>http://www.blogjava.net/pixysoft/archive/2008/12/17/246851.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/pixysoft/comments/commentRss/246851.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/pixysoft/services/trackbacks/246851.html</trackback:ping><description><![CDATA[reference:<br />
&nbsp;part1<br />
<br />
<br />
1. in package explorer, change myService.java:<br />
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #0000ff">package</span><span style="color: #000000">&nbsp;com.service;<br />
</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">class</span><span style="color: #000000">&nbsp;myService&nbsp;{<br />
</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;String&nbsp;getusername(String&nbsp;name){<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">Hello&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">+</span><span style="color: #000000">name</span><span style="color: #000000">+</span><span style="color: #000000">"</span><span style="color: #000000">,this&nbsp;is&nbsp;an&nbsp;Axis&nbsp;Web&nbsp;Service</span><span style="color: #000000">"</span><span style="color: #000000">;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}</span></div>
and ctrl+1 to solve the package problem( or you can create dir and move file yourself)<br />
<br />
2.in WebContent/WEB-INF/, create server-config.wsdd<br />
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #0000ff">&lt;</span><span style="color: #800000">deployment&nbsp;</span><span style="color: #ff0000">xmlns</span><span style="color: #0000ff">="http://xml.apache.org/axis/wsdd/"</span><span style="color: #ff0000">&nbsp;xmlns:java</span><span style="color: #0000ff">="http://xml.apache.org/axis/wsdd/providers/java"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">handler&nbsp;</span><span style="color: #ff0000">type</span><span style="color: #0000ff">="java:org.apache.axis.handlers.http.URLMapper"</span><span style="color: #ff0000">&nbsp;name</span><span style="color: #0000ff">="URLMapper"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">service&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="myService"</span><span style="color: #ff0000">&nbsp;provider</span><span style="color: #0000ff">="java:RPC"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">parameter&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="className"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="com.service.myService"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">parameter&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="allowedMethods"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="getusername"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">service</span><span style="color: #0000ff">&gt;</span><span style="color: #000000">&nbsp;<br />
</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">transport&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="http"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">requestFlow</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">handler&nbsp;</span><span style="color: #ff0000">type</span><span style="color: #0000ff">="URLMapper"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">requestFlow</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">transport</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">deployment</span><span style="color: #0000ff">&gt;</span></div>
<br />
3. in src/, create <span style="line-height: 150%">myServiceTestorByWSDD.java</span><br />
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;java.net.MalformedURLException;<br />
</span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;java.rmi.RemoteException;<br />
</span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;javax.xml.rpc.ServiceException;<br />
</span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;org.apache.axis.client.Call;<br />
</span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;org.apache.axis.client.Service;<br />
</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">class</span><span style="color: #000000">&nbsp;myServiceTestorByWSDD&nbsp;{<br />
</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;tatic&nbsp;</span><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;main(String[]&nbsp;args)&nbsp;</span><span style="color: #0000ff">throws</span><span style="color: #000000">&nbsp;ServiceException,MalformedURLException,&nbsp;RemoteException&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;endpoint&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000"><a href="http://localhost:8080/oopsaxis1/services/myService">http://localhost:8080/oopsaxis1/services/myService</a></span><span style="color: #000000">;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Service&nbsp;service&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">new</span><span style="color: #000000">&nbsp;Service();&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">&nbsp;创建一个Service实例，注意是必须的！</span><span style="color: #008000"><br />
</span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Call&nbsp;call&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(Call)&nbsp;service.createCall();&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">&nbsp;创建Call实例，也是必须的！</span><span style="color: #008000"><br />
</span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;call.setTargetEndpointAddress(</span><span style="color: #0000ff">new</span><span style="color: #000000">&nbsp;java.net.URL(endpoint));</span><span style="color: #008000">//</span><span style="color: #008000">&nbsp;为Call设置服务的位置</span><span style="color: #008000"><br />
</span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;call.setOperationName(</span><span style="color: #000000">"</span><span style="color: #000000">getusername</span><span style="color: #000000">"</span><span style="color: #000000">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">&nbsp;注意方法名与JavaBeanWS.java中一样！！</span><span style="color: #008000"><br />
</span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;res&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(String)&nbsp;call.invoke(</span><span style="color: #0000ff">new</span><span style="color: #000000">&nbsp;Object[]&nbsp;{&nbsp;</span><span style="color: #000000">"pixysoft</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;});&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">&nbsp;返回String，传入参数</span><span style="color: #008000"><br />
</span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(res);<br />
}<br />
}</span></div>
<br />
4. open tomcat, and :<font style="background-color: #cce8cf">http://localhost:8080/oopsaxis1/servlet/AxisServlet,you can see:<br />
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #000000">And&nbsp;now<img src="http://www.blogjava.net/Images/dot.gif"  alt="" />&nbsp;Some&nbsp;Services<br />
myService&nbsp;(wsdl)&nbsp;<br />
getusername&nbsp;</span></div>
<br />
5. right click <span style="line-height: 150%">myServiceTestorByWSDD.java, run as java application.<br />
<br />
<br />
done!</span><br />
</font>
<img src ="http://www.blogjava.net/pixysoft/aggbug/246851.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pixysoft/" target="_blank">张辰</a> 2008-12-17 13:51 <a href="http://www.blogjava.net/pixysoft/archive/2008/12/17/246851.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oops! Axis quick start ! part 1 -- simple demo</title><link>http://www.blogjava.net/pixysoft/archive/2008/12/17/246849.html</link><dc:creator>张辰</dc:creator><author>张辰</author><pubDate>Wed, 17 Dec 2008 05:40:00 GMT</pubDate><guid>http://www.blogjava.net/pixysoft/archive/2008/12/17/246849.html</guid><wfw:comment>http://www.blogjava.net/pixysoft/comments/246849.html</wfw:comment><comments>http://www.blogjava.net/pixysoft/archive/2008/12/17/246849.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/pixysoft/comments/commentRss/246849.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/pixysoft/services/trackbacks/246849.html</trackback:ping><description><![CDATA[<p><font style="background-color: #cce8cf">reference:<br />
<br />
<font style="background-color: #cce8cf">http://www.cnblogs.com/cy163/archive/2008/11/28/1343516.html</font><br />
<br />
pre-condition:<br />
1.install eclipse<br />
2.install tomcat plugin<br />
<br />
process:<br />
1.download axis lib: <a href="http://http://ws.apache.org/axis"><font style="background-color: #cce8cf">http://ws.apache.org/axis</a><br />
<br />
</font></font></p>
2.&nbsp;set classpath:<br />
<font style="background-color: #cce8cf">1．AXIS_HOME<br />
D:\Java\axis-1_4（这是我的Axis路径）<br />
2．AXIS_LIB<br />
%AXIS_HOME%\lib<br />
3．AXIS_CLASSPATH<br />
%AXIS_LIB%\axis.jar;%AXIS_LIB%\commons-discovery-0.2.jar;%AXIS_LIB%\commons-logging-1.0.4.jar;%AXIS_LIB%\jaxrpc.jar;%AXIS_LIB%\saaj.jar;%AXIS_LIB%\log4j-1.2.8.jar;%AXIS_LIB%\xml-apis.jar;%AXIS_LIB%\xercesImpl.jar;%AXIS_LIB%\wsdl4j-1.5.1.jar;%AXIS_LIB%\activation.jar;%AXIS_LIB%\xmlrpc-2.0.jar<br />
4．CLASSPATH<br />
.;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt.jar; %AXIS_CLASSPATH%;<br />
5．在你的%TOMCAT_HOME%\common\lib下需要加入三个包 activation.jar、mail.jar、tools.jar，注意这三个包是必须的，尽管tools.jar很常见，但这也是运行Axis所必须的包。<br />
<br />
<br />
3.FIle - new - dynamic web project<br />
projectname: oopsaxis1<br />
target runtime: apache tomcat V5.5<br />
<br />
<br />
4. oopsaxis1/WebContent/WEB-INF/lib,add lib from %AXIS_HOME%\lib<br />
axis.jar/axis-ant.jar/commons-log.jar...<br />
<br />
5.oopsaxis1/WebContent/WEB-INF/web.xml,&nbsp; replace by %AXIS_HOME%\webapps\axis\WEB-INF\web.xml<br />
<br />
6.oopsaxis1/src, add java file:<br />
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">class</span><span style="color: #000000">&nbsp;myService<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;String&nbsp;getusername(String&nbsp;name)<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">return</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">Hello&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;name&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">,this&nbsp;is&nbsp;an&nbsp;Axis&nbsp;DII&nbsp;Web&nbsp;Service</span><span style="color: #000000">"</span><span style="color: #000000">;<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}</span></div>
<br />
<br />
7.copy myService to oopsaxis1/WebContent, and rename to myService.jws<br />
<br />
8. right click myService.jws, run as - run on server, you can see:<br />
<font style="background-color: #cce8cf">http://localhost:8080/oopsaxis1/myService.jws</font><br />
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #000000">There&nbsp;is&nbsp;a&nbsp;Web&nbsp;Service&nbsp;here<br />
Click&nbsp;to&nbsp;see&nbsp;the&nbsp;WSDL&nbsp;<br />
</span></div>
click the link, you can see the wsdl<br />
<br />
<br />
9. in eclipse - package explorer - src, new class:<br />
<font style="background-color: #cce8cf">
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #0000ff">package</span><span style="color: #000000">&nbsp;com.oopsaxis;<br />
<br />
</span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;java.net.MalformedURLException;<br />
</span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;java.rmi.RemoteException;<br />
<br />
</span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;javax.xml.rpc.ParameterMode;<br />
</span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;javax.xml.rpc.ServiceException;<br />
<br />
</span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;org.apache.axis.client.Call;<br />
</span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;org.apache.axis.client.Service;<br />
</span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;org.apache.axis.encoding.XMLType;<br />
<br />
</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">class</span><span style="color: #000000">&nbsp;myServiceTestorByjws<br />
{<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">static</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;main(String[]&nbsp;args)&nbsp;</span><span style="color: #0000ff">throws</span><span style="color: #000000">&nbsp;ServiceException,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MalformedURLException,&nbsp;RemoteException<br />
&nbsp;&nbsp;&nbsp;&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;endpoint&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000"><a href="http://localhost:8080/oopsaxis1/myService.jws">http://localhost:8080/oopsaxis1/myService.jws</a></span><span style="color: #000000">;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;name&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;pixysoft</span><span style="color: #000000">"</span><span style="color: #000000">;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Service&nbsp;service&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">new</span><span style="color: #000000">&nbsp;Service();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Call&nbsp;call&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(Call)&nbsp;service.createCall();<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;call.setTargetEndpointAddress(</span><span style="color: #0000ff">new</span><span style="color: #000000">&nbsp;java.net.URL(endpoint));<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;call.addParameter(</span><span style="color: #000000">"</span><span style="color: #000000">param1</span><span style="color: #000000">"</span><span style="color: #000000">,&nbsp;XMLType.XSD_STRING,&nbsp;ParameterMode.IN);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;call.setOperationName(</span><span style="color: #000000">"</span><span style="color: #000000">getusername</span><span style="color: #000000">"</span><span style="color: #000000">);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;call.setReturnType(XMLType.XSD_STRING);<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;ret&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;(String)&nbsp;call.invoke(</span><span style="color: #0000ff">new</span><span style="color: #000000">&nbsp;Object[]&nbsp;{&nbsp;name&nbsp;});<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;System.out.println(</span><span style="color: #000000">"</span><span style="color: #000000">返回结果：</span><span style="color: #000000">"</span><span style="color: #000000">&nbsp;</span><span style="color: #000000">+</span><span style="color: #000000">&nbsp;ret);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
</span></div>
</font><br />
10. right click myServiceTestorByjws, run as java application,you get:<br />
<font style="background-color: #cce8cf">返回结果：Hello pixysoft,this is an Axis DII Web Service</font><br />
<br />
done!<br />
</font>
<img src ="http://www.blogjava.net/pixysoft/aggbug/246849.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pixysoft/" target="_blank">张辰</a> 2008-12-17 13:40 <a href="http://www.blogjava.net/pixysoft/archive/2008/12/17/246849.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oops! Ant reference.</title><link>http://www.blogjava.net/pixysoft/archive/2008/12/05/244584.html</link><dc:creator>张辰</dc:creator><author>张辰</author><pubDate>Fri, 05 Dec 2008 05:41:00 GMT</pubDate><guid>http://www.blogjava.net/pixysoft/archive/2008/12/05/244584.html</guid><wfw:comment>http://www.blogjava.net/pixysoft/comments/244584.html</wfw:comment><comments>http://www.blogjava.net/pixysoft/archive/2008/12/05/244584.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/pixysoft/comments/commentRss/244584.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/pixysoft/services/trackbacks/244584.html</trackback:ping><description><![CDATA[<h1>Using Ant</h1>
<h2><a name="buildfile">Writing a Simple Buildfile</a></h2>
<p>Ant's buildfiles are written in XML. Each buildfile contains one project and at least one (default) target. Targets contain task elements. Each task element of the buildfile can have an <code>id</code> attribute and can later be referred to by the value supplied to this. The value has to be unique. (For additional information, see the <a href="http://ant.apache.org/manual/using.html#tasks">Tasks</a> section below.)</p>
<h3><a name="projects">Projects</a></h3>
<p>A <em>project</em> has three attributes:</p>
<table cellspacing="0" cellpadding="2" border="1">
    <tbody>
        <tr>
            <td valign="top"><strong>Attribute</strong></td>
            <td valign="top"><strong>Description</strong></td>
            <td valign="top" align="center"><strong>Required</strong></td>
        </tr>
        <tr>
            <td valign="top">name</td>
            <td valign="top">the name of the project.</td>
            <td valign="top" align="center">No</td>
        </tr>
        <tr>
            <td valign="top">default</td>
            <td valign="top">the default target to use when no target is supplied.</td>
            <td valign="top" align="center">No; however, <strong>since Ant 1.6.0</strong>, every project includes an implicit target that contains any and all top-level tasks and/or types. This target will always be executed as part of the project's initialization, even when Ant is run with the <a href="http://ant.apache.org/manual/running.html#options">-projecthelp</a> option. </td>
        </tr>
        <tr>
            <td valign="top">basedir</td>
            <td valign="top">the base directory from which all path calculations are done. This attribute might be overridden by setting the "basedir" property beforehand. When this is done, it must be omitted in the project tag. If neither the attribute nor the property have been set, the parent directory of the buildfile will be used.</td>
            <td valign="top" align="center">No</td>
        </tr>
    </tbody>
</table>
<p>Optionally, a description for the project can be provided as a top-level <code>&lt;description&gt;</code> element (see the <a href="http://ant.apache.org/manual/CoreTypes/description.html">description</a> type).</p>
<p>Each project defines one or more <em>targets</em>. A target is a set of <em>tasks</em> you want to be executed. When starting Ant, you can select which target(s) you want to have executed. When no target is given, the project's default is used.</p>
<h3><a name="targets">Targets</a></h3>
<p>A target can depend on other targets. You might have a target for compiling, for example, and a target for creating a distributable. You can only build a distributable when you have compiled first, so the distribute target <em>depends on</em> the compile target. Ant resolves these dependencies.</p>
<p>It should be noted, however, that Ant's <code>depends</code> attribute only specifies the <em>order</em> in which targets should be executed - it does not affect whether the target that specifies the dependency(s) gets executed if the dependent target(s) did not (need to) run. </p>
<p>Ant tries to execute the targets in the <code>depends</code> attribute in the order they appear (from left to right). Keep in mind that it is possible that a target can get executed earlier when an earlier target depends on it:</p>
<blockquote>
<pre>&lt;target name="A"/&gt;
&lt;target name="B" depends="A"/&gt;
&lt;target name="C" depends="B"/&gt;
&lt;target name="D" depends="C,B,A"/&gt;</pre>
</blockquote>
<p>Suppose we want to execute target D. From its <code>depends</code> attribute, you might think that first target C, then B and then A is executed. Wrong! C depends on B, and B depends on A, so first A is executed, then B, then C, and finally D.</p>
<p>In a chain of dependencies stretching back from a given target such as D above, each target gets executed only once, even when more than one target depends on it. Thus, executing the D target will first result in C being called, which in turn will first call B, which in turn will first call A. After A, then B, then C have executed, execution returns to the dependency list of D, which will <u>not</u> call B and A, since they were already called in process of dependency resolution for C and B respectively as dependencies of D. Had no such dependencies been discovered in processing C and B, B and A would have been executed after C in processing D's dependency list.</p>
<p>A target also has the ability to perform its execution if (or unless) a property has been set. This allows, for example, better control on the building process depending on the state of the system (java version, OS, command-line property defines, etc.). To make a target <em>sense</em> this property, you should add the <code>if</code> (or <code>unless</code>) attribute with the name of the property that the target should react to. <strong>Note:</strong> Ant will only check whether the property has been set, the value doesn't matter. A property set to the empty string is still an existing property. For example:</p>
<blockquote>
<pre>&lt;target name="build-module-A" if="module-A-present"/&gt;</pre>
<pre>&lt;target name="build-own-fake-module-A" unless="module-A-present"/&gt;</pre>
</blockquote>
<p>In the first example, if the <code>module-A-present</code> property is set (to any value, e.g. <em>false</em>), the target will be run. In the second example, if the <code>module-A-present</code> property is set (again, to any value), the target will not be run. </p>
<p>Only one propertyname can be specified in the if/unless clause. If you want to check multiple conditions, you can use a dependend target for computing the result for the check:</p>
<blockquote>
<pre>&lt;target name="myTarget" depends="myTarget.check" if="myTarget.run"&gt;
&lt;echo&gt;Files foo.txt and bar.txt are present.&lt;/echo&gt;
&lt;/target&gt;
&lt;target name="myTarget.check"&gt;
&lt;condition property="myTarget.run"&gt;
&lt;and&gt;
&lt;available file="foo.txt"/&gt;
&lt;available file="bar.txt"/&gt;
&lt;/and&gt;
&lt;/condition&gt;
&lt;/target&gt;
</pre>
</blockquote>
<p>If no <code>if</code> and no <code>unless</code> attribute is present, the target will always be executed.</p>
<p><strong>Important:</strong> the <code>if</code> and <code>unless</code> attributes only enable or disable the target to which they are attached. They do not control whether or not targets that a conditional target depends upon get executed. In fact, they do not even get evaluated until the target is about to be executed, and all its predecessors have already run.
<p>The optional <code>description</code> attribute can be used to provide a one-line description of this target, which is printed by the <nobr><code>-projecthelp</code></nobr> command-line option. Targets without such a description are deemed internal and will not be listed, unless either the <nobr><code>-verbose</code></nobr> or <nobr><code>-debug</code></nobr> option is used. </p>
<p>It is a good practice to place your <a href="http://ant.apache.org/manual/CoreTasks/tstamp.html">tstamp</a> tasks in a so-called <em>initialization</em> target, on which all other targets depend. Make sure that target is always the first one in the depends list of the other targets. In this manual, most initialization targets have the name <code>"init"</code>.</p>
<p>If the depends attribute and the if/unless attribute are set, the depends attribute is executed first.</p>
<p>A target has the following attributes:</p>
<table cellspacing="0" cellpadding="2" border="1">
    <tbody>
        <tr>
            <td valign="top"><strong>Attribute</strong></td>
            <td valign="top"><strong>Description</strong></td>
            <td valign="top" align="center"><strong>Required</strong></td>
        </tr>
        <tr>
            <td valign="top">name</td>
            <td valign="top">the name of the target.</td>
            <td valign="top" align="center">Yes</td>
        </tr>
        <tr>
            <td valign="top">depends</td>
            <td valign="top">a comma-separated list of names of targets on which this target depends.</td>
            <td valign="top" align="center">No</td>
        </tr>
        <tr>
            <td valign="top">if</td>
            <td valign="top">the name of the property that must be set in order for this target to execute.</td>
            <td valign="top" align="center">No</td>
        </tr>
        <tr>
            <td valign="top">unless</td>
            <td valign="top">the name of the property that must not be set in order for this target to execute.</td>
            <td valign="top" align="center">No</td>
        </tr>
        <tr>
            <td valign="top">description</td>
            <td valign="top">a short description of this target's function.</td>
            <td valign="top" align="center">No</td>
        </tr>
    </tbody>
</table>
<p>&nbsp;</p>
<p>A target name can be any alphanumeric string valid in the encoding of the XML file. The empty string "" is in this set, as is comma "," and space " ". Please avoid using these, as they will not be supported in future Ant versions because of all the confusion they cause. IDE support of unusual target names, or any target name containing spaces, varies with the IDE.</p>
<p>Targets beginning with a hyphen such as <code>"-restart"</code> are valid, and can be used to name targets that should not be called directly from the command line.</p>
<h3><a name="tasks">Tasks</a></h3>
<p>A task is a piece of code that can be executed.</p>
<p>A task can have multiple attributes (or arguments, if you prefer). The value of an attribute might contain references to a property. These references will be resolved before the task is executed.</p>
<p>Tasks have a common structure:</p>
<blockquote>
<pre>&lt;<em>name</em> <em>attribute1</em>="<em>value1</em>" <em>attribute2</em>="<em>value2</em>" ... /&gt;</pre>
</blockquote>
<p>where <em>name</em> is the name of the task, <em>attributeN</em> is the attribute name, and <em>valueN</em> is the value for this attribute.</p>
<p>There is a set of <a href="http://ant.apache.org/manual/coretasklist.html" target="navFrame">built-in tasks</a>, along with a number of <a href="http://ant.apache.org/manual/optionaltasklist.html" target="navFrame">optional tasks</a>, but it is also very easy to <a href="http://ant.apache.org/manual/develop.html#writingowntask">write your own</a>.</p>
<p>All tasks share a task name attribute. The value of this attribute will be used in the logging messages generated by Ant.</p>
Tasks can be assigned an <code>id</code> attribute:
<blockquote>
<pre>&lt;<em>taskname</em> id="<em>taskID</em>" ... /&gt;</pre>
</blockquote>where <em>taskname</em> is the name of the task, and <em>taskID</em> is a unique identifier for this task. You can refer to the corresponding task object in scripts or other tasks via this name. For example, in scripts you could do:
<blockquote>
<pre>&lt;script ... &gt;
task1.setFoo("bar");
&lt;/script&gt;
</pre>
</blockquote>to set the <code>foo</code> attribute of this particular task instance. In another task (written in Java), you can access the instance via <code>project.getReference("task1")</code>.
<p>Note<sup>1</sup>: If "task1" has not been run yet, then it has not been configured (ie., no attributes have been set), and if it is going to be configured later, anything you've done to the instance may be overwritten. </p>
<p>Note<sup>2</sup>: Future versions of Ant will most likely <em>not</em> be backward-compatible with this behaviour, since there will likely be no task instances at all, only proxies. </p>
<h3><a name="properties">Properties</a></h3>
<p>A project can have a set of properties. These might be set in the buildfile by the <a href="http://ant.apache.org/manual/CoreTasks/property.html">property</a> task, or might be set outside Ant. A property has a name and a value; the name is case-sensitive. Properties may be used in the value of task attributes. This is done by placing the property name between "<code>${</code>" and "<code>}</code>" in the attribute value. For example, if there is a "builddir" property with the value "build", then this could be used in an attribute like this: <code>${builddir}/classes</code>. This is resolved at run-time as <code>build/classes</code>.</p>
<p>In the event you should need to include this construct literally (i.e. without property substitutions), simply "escape" the '$' character by doubling it. To continue the previous example:
<pre>  &lt;echo&gt;$${builddir}=${builddir}&lt;/echo&gt;</pre>
will echo this message:
<pre>  ${builddir}=build/classes</pre>
<p>&nbsp;</p>
<p>In order to maintain backward compatibility with older Ant releases, a single '$' character encountered apart from a property-like construct (including a matched pair of french braces) will be interpreted literally; that is, as '$'. The "correct" way to specify this literal character, however, is by using the escaping mechanism unconditionally, so that "$$" is obtained by specifying "$$$$". Mixing the two approaches yields unpredictable results, as "$$$" results in "$$".</p>
<h3><a name="built-in-props">Built-in Properties</a></h3>
<p>Ant provides access to all system properties as if they had been defined using a <code>&lt;property&gt;</code> task. For example, <code>${os.name}</code> expands to the name of the operating system.</p>
<p>For a list of system properties see <a href="http://java.sun.com/j2se/1.3/docs/api/java/lang/System.html#getProperties()">the Javadoc of System.getProperties</a>. </p>
<p>In addition, Ant has some built-in properties:</p>
<pre>basedir             the absolute path of the project's basedir (as set
with the basedir attribute of <a href="http://ant.apache.org/manual/using.html#projects">&lt;project&gt;)</a>.
ant.file            the absolute path of the buildfile.
ant.version         the version of Ant
ant.project.name    the name of the project that is currently executing;
it is set in the name attribute of &lt;project&gt;.
ant.java.version    the JVM version Ant detected; currently it can hold
the values "1.2", "1.3", "1.4" and "1.5".
</pre>
<p>There is also another property, but this is set by the launcher script and therefore maybe not set inside IDEs:</p>
<pre>ant.home            home directory of Ant
</pre>
<a name="example">
<h3>Example Buildfile</h3>
</a>
<pre>&lt;project name="MyProject" default="dist" basedir="."&gt;
&lt;description&gt;
simple example build file
&lt;/description&gt;
&lt;!-- set global properties for this build --&gt;
&lt;property name="src" location="src"/&gt;
&lt;property name="build" location="build"/&gt;
&lt;property name="dist"  location="dist"/&gt;
&lt;target name="init"&gt;
&lt;!-- Create the time stamp --&gt;
&lt;tstamp/&gt;
&lt;!-- Create the build directory structure used by compile --&gt;
&lt;mkdir dir="${build}"/&gt;
&lt;/target&gt;
&lt;target name="compile" depends="init"
description="compile the source " &gt;
&lt;!-- Compile the java code from ${src} into ${build} --&gt;
&lt;javac srcdir="${src}" destdir="${build}"/&gt;
&lt;/target&gt;
&lt;target name="dist" depends="compile"
description="generate the distribution" &gt;
&lt;!-- Create the distribution directory --&gt;
&lt;mkdir dir="${dist}/lib"/&gt;
&lt;!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file --&gt;
&lt;jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/&gt;
&lt;/target&gt;
&lt;target name="clean"
description="clean up" &gt;
&lt;!-- Delete the ${build} and ${dist} directory trees --&gt;
&lt;delete dir="${build}"/&gt;
&lt;delete dir="${dist}"/&gt;
&lt;/target&gt;
&lt;/project&gt;
</pre>
<p>Notice that we are declaring properties outside any target. As of Ant 1.6 all tasks can be declared outside targets (earlier version only allowed <tt>&lt;property&gt;</tt>,<tt>&lt;typedef&gt;</tt> and <tt>&lt;taskdef&gt;</tt>). When you do this they are evaluated before any targets are executed. Some tasks will generate build failures if they are used outside of targets as they may cause infinite loops otherwise (<code>&lt;antcall&gt;</code> for example).</p>
<p>We have given some targets descriptions; this causes the <tt>projecthelp</tt> invocation option to list them as public targets with the descriptions; the other target is internal and not listed.
<p>Finally, for this target to work the source in the <tt>src</tt> subdirectory should be stored in a directory tree which matches the package names. Check the <tt>&lt;javac&gt;</tt> task for details. <a name="filters">
<h3>Token Filters</h3>
</a>
<p>A project can have a set of tokens that might be automatically expanded if found when a file is copied, when the filtering-copy behavior is selected in the tasks that support this. These might be set in the buildfile by the <a href="http://ant.apache.org/manual/CoreTasks/filter.html">filter</a> task.</p>
<p>Since this can potentially be a very harmful behavior, the tokens in the files <strong>must</strong> be of the form <code>@</code><em>token</em><code>@</code>, where <em>token</em> is the token name that is set in the <code>&lt;filter&gt;</code> task. This token syntax matches the syntax of other build systems that perform such filtering and remains sufficiently orthogonal to most programming and scripting languages, as well as with documentation systems.</p>
<p>Note: If a token with the format <code>@</code><em>token</em><code>@</code> is found in a file, but no filter is associated with that token, no changes take place; therefore, no escaping method is available - but as long as you choose appropriate names for your tokens, this should not cause problems.</p>
<p><strong>Warning:</strong> If you copy binary files with filtering turned on, you can corrupt the files. This feature should be used with text files <em>only</em>.</p>
<h3><a name="path">Path-like Structures</a></h3>
<p>You can specify <code>PATH</code>- and <code>CLASSPATH</code>-type references using both "<code>:</code>" and "<code>;</code>" as separator characters. Ant will convert the separator to the correct character of the current operating system.</p>
<p>Wherever path-like values need to be specified, a nested element can be used. This takes the general form of:</p>
<pre>    &lt;classpath&gt;
&lt;pathelement path="${classpath}"/&gt;
&lt;pathelement location="lib/helper.jar"/&gt;
&lt;/classpath&gt;
</pre>
<p>The <code>location</code> attribute specifies a single file or directory relative to the project's base directory (or an absolute filename), while the <code>path</code> attribute accepts colon- or semicolon-separated lists of locations. The <code>path</code> attribute is intended to be used with predefined paths - in any other case, multiple elements with <code>location</code> attributes should be preferred.</p>
<p>As a shortcut, the <code>&lt;classpath&gt;</code> tag supports <code>path</code> and <code>location</code> attributes of its own, so:</p>
<pre>    &lt;classpath&gt;
&lt;pathelement path="${classpath}"/&gt;
&lt;/classpath&gt;
</pre>
<p>can be abbreviated to:</p>
<pre>    &lt;classpath path="${classpath}"/&gt;
</pre>
<p>In addition, one or more <a href="http://ant.apache.org/manual/CoreTypes/resources.html#collection">Resource Collection</a>s can be specified as nested elements (these must consist of <a href="http://ant.apache.org/manual/CoreTypes/resources.html#file">file</a>-type resources only). Additionally, it should be noted that although resource collections are processed in the order encountered, certain resource collection types such as <a href="http://ant.apache.org/manual/CoreTypes/fileset.html">fileset</a>, <a href="http://ant.apache.org/manual/CoreTypes/dirset.html">dirset</a> and <a href="http://ant.apache.org/manual/CoreTypes/resources.html#files">files</a> are undefined in terms of order.</p>
<pre>    &lt;classpath&gt;
&lt;pathelement path="${classpath}"/&gt;
&lt;fileset dir="lib"&gt;
&lt;include name="**/*.jar"/&gt;
&lt;/fileset&gt;
&lt;pathelement location="classes"/&gt;
&lt;dirset dir="${build.dir}"&gt;
&lt;include name="apps/**/classes"/&gt;
&lt;exclude name="apps/**/*Test*"/&gt;
&lt;/dirset&gt;
&lt;filelist refid="third-party_jars"/&gt;
&lt;/classpath&gt;
</pre>
<p>This builds a path that holds the value of <code>${classpath}</code>, followed by all jar files in the <code>lib</code> directory, the <code>classes</code> directory, all directories named <code>classes</code> under the <code>apps</code> subdirectory of <code>${build.dir}</code>, except those that have the text <code>Test</code> in their name, and the files specified in the referenced FileList.</p>
<p>If you want to use the same path-like structure for several tasks, you can define them with a <code>&lt;path&gt;</code> element at the same level as <em>target</em>s, and reference them via their <em>id</em> attribute--see <a href="http://ant.apache.org/manual/using.html#references">References</a> for an example.</p>
<p>A path-like structure can include a reference to another path-like structure (a path being itself a resource collection) via nested <code>&lt;path&gt;</code> elements:</p>
<pre>    &lt;path id="base.path"&gt;
&lt;pathelement path="${classpath}"/&gt;
&lt;fileset dir="lib"&gt;
&lt;include name="**/*.jar"/&gt;
&lt;/fileset&gt;
&lt;pathelement location="classes"/&gt;
&lt;/path&gt;
&lt;path id="tests.path"&gt;
&lt;path refid="base.path"/&gt;
&lt;pathelement location="testclasses"/&gt;
&lt;/path&gt;
</pre>
The shortcuts previously mentioned for <code>&lt;classpath&gt;</code> are also valid for <code>&lt;path&gt;</code>.For example:
<pre>    &lt;path id="base.path"&gt;
&lt;pathelement path="${classpath}"/&gt;
&lt;/path&gt;
</pre>
can be written as:
<pre>    &lt;path id="base.path" path="${classpath}"/&gt;
</pre>
<h4><a name="pathshortcut">Path Shortcut</a></h4>
<p>In Ant 1.6 a shortcut for converting paths to OS specific strings in properties has been added. One can use the expression ${toString:<em>pathreference</em>} to convert a path element reference to a string that can be used for a path argument. For example: </p>
<pre>  &lt;path id="lib.path.ref"&gt;
&lt;fileset dir="lib" includes="*.jar"/&gt;
&lt;/path&gt;
&lt;javac srcdir="src" destdir="classes"&gt;
&lt;compilerarg arg="-Xbootstrap/p:${toString:lib.path.ref}"/&gt;
&lt;/javac&gt;
</pre>
<h3><a name="arg">Command-line Arguments</a></h3>
<p>Several tasks take arguments that will be passed to another process on the command line. To make it easier to specify arguments that contain space characters, nested <code>arg</code> elements can be used.</p>
<table cellspacing="0" cellpadding="2" border="1">
    <tbody>
        <tr>
            <td valign="top" width="12%"><strong>Attribute</strong></td>
            <td valign="top" width="78%"><strong>Description</strong></td>
            <td valign="top" width="10%"><strong>Required</strong></td>
        </tr>
        <tr>
            <td valign="top">value</td>
            <td valign="top">a single command-line argument; can contain space characters.</td>
            <td align="center" rowspan="5">Exactly one of these.</td>
        </tr>
        <tr>
            <td valign="top">file</td>
            <td valign="top">The name of a file as a single command-line argument; will be replaced with the absolute filename of the file.</td>
        </tr>
        <tr>
            <td valign="top">path</td>
            <td valign="top">A string that will be treated as a path-like string as a single command-line argument; you can use <code>;</code> or <code>:</code> as path separators and Ant will convert it to the platform's local conventions.</td>
        </tr>
        <tr>
            <td valign="top">pathref</td>
            <td valign="top"><a href="http://ant.apache.org/manual/using.html#references">Reference</a> to a path defined elsewhere. Ant will convert it to the platform's local conventions.</td>
        </tr>
        <tr>
            <td valign="top">line</td>
            <td valign="top">a space-delimited list of command-line arguments.</td>
        </tr>
    </tbody>
</table>
<p>It is highly recommended to avoid the <code>line</code> version when possible. Ant will try to split the command line in a way similar to what a (Unix) shell would do, but may create something that is very different from what you expect under some circumstances.</p>
<h4>Examples</h4>
<blockquote>
<pre>  &lt;arg value="-l -a"/&gt;
</pre>
</blockquote>
<p>is a single command-line argument containing a space character, <em>not</em> separate commands "-l" and "-a".</p>
<blockquote>
<pre>  &lt;arg line="-l -a"/&gt;
</pre>
</blockquote>
<p>This is a command line with two separate arguments, "-l" and "-a".</p>
<blockquote>
<pre>  &lt;arg path="/dir;/dir2:\dir3"/&gt;
</pre>
</blockquote>
<p>is a single command-line argument with the value <code>\dir;\dir2;\dir3</code> on DOS-based systems and <code>/dir:/dir2:/dir3</code> on Unix-like systems.</p>
<h3><a name="references">References</a></h3>
<p>Any project element can be assigned an identifier using its <code>id</code> attribute. In most cases the element can subsequently be referenced by specifying the <code>refid</code> attribute on an element of the same type. This can be useful if you are going to replicate the same snippet of XML over and over again--using a <code>&lt;classpath&gt;</code> structure more than once, for example.</p>
<p>The following example:</p>
<blockquote>
<pre>&lt;project ... &gt;
&lt;target ... &gt;
&lt;rmic ...&gt;
&lt;classpath&gt;
&lt;pathelement location="lib/"/&gt;
&lt;pathelement path="${java.class.path}/"/&gt;
&lt;pathelement path="${additional.path}"/&gt;
&lt;/classpath&gt;
&lt;/rmic&gt;
&lt;/target&gt;
&lt;target ... &gt;
&lt;javac ...&gt;
&lt;classpath&gt;
&lt;pathelement location="lib/"/&gt;
&lt;pathelement path="${java.class.path}/"/&gt;
&lt;pathelement path="${additional.path}"/&gt;
&lt;/classpath&gt;
&lt;/javac&gt;
&lt;/target&gt;
&lt;/project&gt;
</pre>
</blockquote>
<p>could be rewritten as:</p>
<blockquote>
<pre>&lt;project ... &gt;
&lt;path id="project.class.path"&gt;
&lt;pathelement location="lib/"/&gt;
&lt;pathelement path="${java.class.path}/"/&gt;
&lt;pathelement path="${additional.path}"/&gt;
&lt;/path&gt;
&lt;target ... &gt;
&lt;rmic ...&gt;
&lt;classpath refid="project.class.path"/&gt;
&lt;/rmic&gt;
&lt;/target&gt;
&lt;target ... &gt;
&lt;javac ...&gt;
&lt;classpath refid="project.class.path"/&gt;
&lt;/javac&gt;
&lt;/target&gt;
&lt;/project&gt;
</pre>
</blockquote>
<p>All tasks that use nested elements for <a href="http://ant.apache.org/manual/CoreTypes/patternset.html">PatternSet</a>s, <a href="http://ant.apache.org/manual/CoreTypes/fileset.html">FileSet</a>s, <a href="http://ant.apache.org/manual/CoreTypes/zipfileset.html">ZipFileSet</a>s or <a href="http://ant.apache.org/manual/using.html#path">path-like structures</a> accept references to these structures as shown in the examples. Using <code>refid</code> on a task will ordinarily have the same effect (referencing a task already declared), but the user should be aware that the interpretation of this attribute is dependent on the implementation of the element upon which it is specified. Some tasks (the <a href="http://ant.apache.org/manual/CoreTasks/property.html">property</a> task is a handy example) deliberately assign a different meaning to <code>refid</code>.</p>
<h3><a name="external-tasks">Use of external tasks</a></h3>
Ant supports a plugin mechanism for using third party tasks. For using them you have to do two steps:
<ol>
    <li>place their implementation somewhere where Ant can find them
    <li>declare them. </li>
</ol>
Don't add anything to the CLASSPATH environment variable - this is often the reason for very obscure errors. Use Ant's own <a href="http://ant.apache.org/manual/install.html#optionalTasks">mechanisms</a> for adding libraries:
<ul>
    <li>via command line argument <code>-lib</code>
    <li>adding to <code>${user.home}/.ant/lib</code>
    <li>adding to <code>${ant.home}/lib</code> </li>
</ul>
For the declaration there are several ways:
<ul>
    <li>declare a single task per using instruction using <code>&lt;<a href="http://ant.apache.org/manual/CoreTasks/taskdef.html">taskdef</a> name="taskname" classname="ImplementationClass"/&gt;</code> <br />
    <code>&lt;taskdef name="for" classname="net.sf.antcontrib.logic.For" /&gt; &lt;for ... /&gt;</code>
    <li>declare a bundle of tasks using a properties-file holding these taskname-ImplementationClass-pairs and <code>&lt;taskdef&gt;</code> <br />
    <code>&lt;taskdef resource="net/sf/antcontrib/antcontrib.properties" /&gt; &lt;for ... /&gt;</code>
    <li>declare a bundle of tasks using a <a href="http://ant.apache.org/manual/CoreTypes/antlib.html">xml-file</a> holding these taskname-ImplementationClass-pairs and <code>&lt;taskdef&gt;</code> <br />
    <code>&lt;taskdef resource="net/sf/antcontrib/antlib.xml" /&gt; &lt;for ... /&gt;</code>
    <li>declare a bundle of tasks using a xml-file named antlib.xml, XML-namespace and <a href="http://ant.apache.org/manual/CoreTypes/antlib.html#antlibnamespace"><code>antlib:</code> protocoll handler</a> <br />
    <code>&lt;project xmlns:ac="antlib:net.sf.antconrib"/&gt; &lt;ac:for ... /&gt;</code> </li>
</ul>
If you need a special function, you should
<ol>
    <li>have a look at this manual, because Ant provides lot of tasks
    <li>have a look at the external task page in the <a href="http://ant.apache.org/external.html">manual</a> (or better <a href="http://ant.apache.org/external.html">online</a>)
    <li>have a look at the external task <a href="http://wiki.apache.org/ant/AntExternalTaskdefs">wiki page</a>
    <li>ask on the <a href="http://ant.apache.org/mail.html#User%20List">Ant user</a> list
    <li><a href="http://ant.apache.org/manual/tutorial-writing-tasks.html">implement </a>(and share) your own </li>
</ol>
<img src ="http://www.blogjava.net/pixysoft/aggbug/244584.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pixysoft/" target="_blank">张辰</a> 2008-12-05 13:41 <a href="http://www.blogjava.net/pixysoft/archive/2008/12/05/244584.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oops! Ant quick start 4 ! - 包含junit</title><link>http://www.blogjava.net/pixysoft/archive/2008/12/04/244377.html</link><dc:creator>张辰</dc:creator><author>张辰</author><pubDate>Thu, 04 Dec 2008 07:03:00 GMT</pubDate><guid>http://www.blogjava.net/pixysoft/archive/2008/12/04/244377.html</guid><wfw:comment>http://www.blogjava.net/pixysoft/comments/244377.html</wfw:comment><comments>http://www.blogjava.net/pixysoft/archive/2008/12/04/244377.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/pixysoft/comments/commentRss/244377.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/pixysoft/services/trackbacks/244377.html</trackback:ping><description><![CDATA[1. 在src目录下面添加文件：HelloWorldTest.java<br />
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">class</span><span style="color: #000000">&nbsp;HelloWorldTest&nbsp;</span><span style="color: #0000ff">extends</span><span style="color: #000000">&nbsp;junit.framework.TestCase&nbsp;{<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;testNothing()&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;testWillAlwaysFail()&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fail(</span><span style="color: #000000">"</span><span style="color: #000000">An&nbsp;error&nbsp;message</span><span style="color: #000000">"</span><span style="color: #000000">);<br />
&nbsp;&nbsp;&nbsp;&nbsp;}<br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
}</span></div>
<br />
2.在lib目录下面添加junit.jar类<br />
<br />
3.修改build.xml文件如下：<br />
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #0000ff">&lt;</span><span style="color: #800000">project&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="HelloWorld"</span><span style="color: #ff0000">&nbsp;basedir</span><span style="color: #0000ff">="."</span><span style="color: #ff0000">&nbsp;default</span><span style="color: #0000ff">="main"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="src.dir"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="src"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="build.dir"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="build"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="classes.dir"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="${build.dir}/classes"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="jar.dir"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="${build.dir}/jar"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="lib.dir"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="lib"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">path&nbsp;</span><span style="color: #ff0000">id</span><span style="color: #0000ff">="classpath"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">fileset&nbsp;</span><span style="color: #ff0000">dir</span><span style="color: #0000ff">="${lib.dir}"</span><span style="color: #ff0000">&nbsp;includes</span><span style="color: #0000ff">="**/*.jar"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">path</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="main-class"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="oata.HelloWorld"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
<br />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="clean"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">delete&nbsp;</span><span style="color: #ff0000">dir</span><span style="color: #0000ff">="${build.dir}"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="compile"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">mkdir&nbsp;</span><span style="color: #ff0000">dir</span><span style="color: #0000ff">="${classes.dir}"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">javac&nbsp;</span><span style="color: #ff0000">srcdir</span><span style="color: #0000ff">="${src.dir}"</span><span style="color: #ff0000">&nbsp;destdir</span><span style="color: #0000ff">="${classes.dir}"</span><span style="color: #ff0000">&nbsp;classpathref</span><span style="color: #0000ff">="classpath"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">copy&nbsp;</span><span style="color: #ff0000">todir</span><span style="color: #0000ff">="${classes.dir}"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">fileset&nbsp;</span><span style="color: #ff0000">dir</span><span style="color: #0000ff">="${src.dir}"</span><span style="color: #ff0000">&nbsp;excludes</span><span style="color: #0000ff">="**/*.java"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">copy</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="jar"</span><span style="color: #ff0000">&nbsp;depends</span><span style="color: #0000ff">="compile"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">mkdir&nbsp;</span><span style="color: #ff0000">dir</span><span style="color: #0000ff">="${jar.dir}"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">jar&nbsp;</span><span style="color: #ff0000">destfile</span><span style="color: #0000ff">="${jar.dir}/${ant.project.name}.jar"</span><span style="color: #ff0000">&nbsp;basedir</span><span style="color: #0000ff">="${classes.dir}"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">manifest</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">attribute&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="Main-Class"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="${main-class}"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">manifest</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">jar</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="run"</span><span style="color: #ff0000">&nbsp;depends</span><span style="color: #0000ff">="jar"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">java&nbsp;</span><span style="color: #ff0000">fork</span><span style="color: #0000ff">="true"</span><span style="color: #ff0000">&nbsp;classname</span><span style="color: #0000ff">="${main-class}"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">classpath</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">path&nbsp;</span><span style="color: #ff0000">refid</span><span style="color: #0000ff">="classpath"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">path&nbsp;</span><span style="color: #ff0000">id</span><span style="color: #0000ff">="application"</span><span style="color: #ff0000">&nbsp;location</span><span style="color: #0000ff">="${jar.dir}/${ant.project.name}.jar"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">classpath</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">java</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="junit"</span><span style="color: #ff0000">&nbsp;depends</span><span style="color: #0000ff">="jar"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">junit&nbsp;</span><span style="color: #ff0000">printsummary</span><span style="color: #0000ff">="yes"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">classpath</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">path&nbsp;</span><span style="color: #ff0000">refid</span><span style="color: #0000ff">="classpath"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">path&nbsp;</span><span style="color: #ff0000">refid</span><span style="color: #0000ff">="application"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">classpath</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">batchtest&nbsp;</span><span style="color: #ff0000">fork</span><span style="color: #0000ff">="yes"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">fileset&nbsp;</span><span style="color: #ff0000">dir</span><span style="color: #0000ff">="${src.dir}"</span><span style="color: #ff0000">&nbsp;includes</span><span style="color: #0000ff">="*Test.java"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">batchtest</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">junit</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="clean-build"</span><span style="color: #ff0000">&nbsp;depends</span><span style="color: #0000ff">="clean,jar"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="main"</span><span style="color: #ff0000">&nbsp;depends</span><span style="color: #0000ff">="clean,run"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
<br />
</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">project</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
</span></div>
<br />
注：修改地方如下：<br />
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;<img src="http://www.blogjava.net/Images/dot.gif"  alt="" /><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="run"</span><span style="color: #ff0000">&nbsp;depends</span><span style="color: #0000ff">="jar"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">java&nbsp;</span><span style="color: #ff0000">fork</span><span style="color: #0000ff">="true"</span><span style="color: #ff0000">&nbsp;classname</span><span style="color: #0000ff">="${main-class}"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">classpath</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">path&nbsp;</span><span style="color: #ff0000">refid</span><span style="color: #0000ff">="classpath"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">path&nbsp;</span><span style="color: #ff0000">id</span><span style="color: #0000ff">="application"</span><span style="color: #ff0000">&nbsp;location</span><span style="color: #0000ff">="${jar.dir}/${ant.project.name}.jar"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">classpath</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">java</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="junit"</span><span style="color: #ff0000">&nbsp;depends</span><span style="color: #0000ff">="jar"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">junit&nbsp;</span><span style="color: #ff0000">printsummary</span><span style="color: #0000ff">="yes"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">classpath</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">path&nbsp;</span><span style="color: #ff0000">refid</span><span style="color: #0000ff">="classpath"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">path&nbsp;</span><span style="color: #ff0000">refid</span><span style="color: #0000ff">="application"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">classpath</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">batchtest&nbsp;</span><span style="color: #ff0000">fork</span><span style="color: #0000ff">="yes"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">fileset&nbsp;</span><span style="color: #ff0000">dir</span><span style="color: #0000ff">="${src.dir}"</span><span style="color: #ff0000">&nbsp;includes</span><span style="color: #0000ff">="*Test.java"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">batchtest</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">junit</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;<img src="http://www.blogjava.net/Images/dot.gif"  alt="" /><br />
<br />
</span></div>
<br />
<br />
6运行，得到结果：<br />
...<br />
junit:<br />
&nbsp;&nbsp;&nbsp; [junit] Running HelloWorldTest<br />
&nbsp;&nbsp;&nbsp; [junit] Tests run: 2, Failures: 1, Errors: 0, Time elapsed: 0,01 sec<br />
&nbsp;&nbsp;&nbsp; [junit] Test HelloWorldTest FAILED<br />
<br />
BUILD SUCCESSFUL<br />
...<br />
<img src ="http://www.blogjava.net/pixysoft/aggbug/244377.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pixysoft/" target="_blank">张辰</a> 2008-12-04 15:03 <a href="http://www.blogjava.net/pixysoft/archive/2008/12/04/244377.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oops! Ant quick start  3 ! - 包含外部类</title><link>http://www.blogjava.net/pixysoft/archive/2008/12/04/244366.html</link><dc:creator>张辰</dc:creator><author>张辰</author><pubDate>Thu, 04 Dec 2008 06:22:00 GMT</pubDate><guid>http://www.blogjava.net/pixysoft/archive/2008/12/04/244366.html</guid><wfw:comment>http://www.blogjava.net/pixysoft/comments/244366.html</wfw:comment><comments>http://www.blogjava.net/pixysoft/archive/2008/12/04/244366.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/pixysoft/comments/commentRss/244366.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/pixysoft/services/trackbacks/244366.html</trackback:ping><description><![CDATA[1.在上文基础上，修改源代码 HelloWorld.java<br />
<br />
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #0000ff">package</span><span style="color: #000000">&nbsp;oata;<br />
<br />
</span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;org.apache.log4j.Logger;<br />
</span><span style="color: #0000ff">import</span><span style="color: #000000">&nbsp;org.apache.log4j.BasicConfigurator;<br />
<br />
</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">class</span><span style="color: #000000">&nbsp;HelloWorld&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">static</span><span style="color: #000000">&nbsp;Logger&nbsp;logger&nbsp;</span><span style="color: #000000">=</span><span style="color: #000000">&nbsp;Logger.getLogger(HelloWorld.</span><span style="color: #0000ff">class</span><span style="color: #000000">);<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">public</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">static</span><span style="color: #000000">&nbsp;</span><span style="color: #0000ff">void</span><span style="color: #000000">&nbsp;main(String[]&nbsp;args)&nbsp;{<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BasicConfigurator.configure();<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;logger.info(</span><span style="color: #000000">"</span><span style="color: #000000">Hello&nbsp;World</span><span style="color: #000000">"</span><span style="color: #000000">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #008000">//</span><span style="color: #008000">&nbsp;the&nbsp;old&nbsp;SysO-statement</span><span style="color: #008000"><br />
</span><span style="color: #000000">&nbsp;&nbsp;&nbsp;&nbsp;}<br />
}<br />
</span></div>
<br />
2. 在javademo目录下面添加lib目录，里面添加log4j的jar文件<br />
<br />
3.修改build.xml，<br />
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #0000ff">&lt;</span><span style="color: #800000">project&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="HelloWorld"</span><span style="color: #ff0000">&nbsp;basedir</span><span style="color: #0000ff">="."</span><span style="color: #ff0000">&nbsp;default</span><span style="color: #0000ff">="main"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="src.dir"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="src"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="build.dir"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="build"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="classes.dir"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="${build.dir}/classes"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="jar.dir"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="${build.dir}/jar"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="lib.dir"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="lib"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">path&nbsp;</span><span style="color: #ff0000">id</span><span style="color: #0000ff">="classpath"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">fileset&nbsp;</span><span style="color: #ff0000">dir</span><span style="color: #0000ff">="${lib.dir}"</span><span style="color: #ff0000">&nbsp;includes</span><span style="color: #0000ff">="**/*.jar"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">path</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="main-class"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="oata.HelloWorld"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
<br />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="clean"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">delete&nbsp;</span><span style="color: #ff0000">dir</span><span style="color: #0000ff">="${build.dir}"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="compile"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">mkdir&nbsp;</span><span style="color: #ff0000">dir</span><span style="color: #0000ff">="${classes.dir}"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">javac&nbsp;</span><span style="color: #ff0000">srcdir</span><span style="color: #0000ff">="${src.dir}"</span><span style="color: #ff0000">&nbsp;destdir</span><span style="color: #0000ff">="${classes.dir}"</span><span style="color: #ff0000">&nbsp;classpathref</span><span style="color: #0000ff">="classpath"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="jar"</span><span style="color: #ff0000">&nbsp;depends</span><span style="color: #0000ff">="compile"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">mkdir&nbsp;</span><span style="color: #ff0000">dir</span><span style="color: #0000ff">="${jar.dir}"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">jar&nbsp;</span><span style="color: #ff0000">destfile</span><span style="color: #0000ff">="${jar.dir}/${ant.project.name}.jar"</span><span style="color: #ff0000">&nbsp;basedir</span><span style="color: #0000ff">="${classes.dir}"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">manifest</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">attribute&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="Main-Class"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="${main-class}"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">manifest</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">jar</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="run"</span><span style="color: #ff0000">&nbsp;depends</span><span style="color: #0000ff">="jar"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">java&nbsp;</span><span style="color: #ff0000">fork</span><span style="color: #0000ff">="true"</span><span style="color: #ff0000">&nbsp;classname</span><span style="color: #0000ff">="${main-class}"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">classpath</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">path&nbsp;</span><span style="color: #ff0000">refid</span><span style="color: #0000ff">="classpath"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">path&nbsp;</span><span style="color: #ff0000">location</span><span style="color: #0000ff">="${jar.dir}/${ant.project.name}.jar"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">classpath</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">java</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="clean-build"</span><span style="color: #ff0000">&nbsp;depends</span><span style="color: #0000ff">="clean,jar"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="main"</span><span style="color: #ff0000">&nbsp;depends</span><span style="color: #0000ff">="clean,run"</span><span style="color: #ff0000">&nbsp;</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
<br />
</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">project</span><span style="color: #0000ff">&gt;</span></div>
<br />
4. 运行ant<br />
<img src ="http://www.blogjava.net/pixysoft/aggbug/244366.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pixysoft/" target="_blank">张辰</a> 2008-12-04 14:22 <a href="http://www.blogjava.net/pixysoft/archive/2008/12/04/244366.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Oops! Ant quick start 2 ! - ant compile</title><link>http://www.blogjava.net/pixysoft/archive/2008/12/04/244339.html</link><dc:creator>张辰</dc:creator><author>张辰</author><pubDate>Thu, 04 Dec 2008 03:50:00 GMT</pubDate><guid>http://www.blogjava.net/pixysoft/archive/2008/12/04/244339.html</guid><wfw:comment>http://www.blogjava.net/pixysoft/comments/244339.html</wfw:comment><comments>http://www.blogjava.net/pixysoft/archive/2008/12/04/244339.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/pixysoft/comments/commentRss/244339.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/pixysoft/services/trackbacks/244339.html</trackback:ping><description><![CDATA[1.接上文，在javademo下面新建文件 build.xml<br />
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #0000ff">&lt;</span><span style="color: #800000">project</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="clean"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">delete&nbsp;</span><span style="color: #ff0000">dir</span><span style="color: #0000ff">="build"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="compile"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">mkdir&nbsp;</span><span style="color: #ff0000">dir</span><span style="color: #0000ff">="build/classes"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">javac&nbsp;</span><span style="color: #ff0000">srcdir</span><span style="color: #0000ff">="src"</span><span style="color: #ff0000">&nbsp;destdir</span><span style="color: #0000ff">="build/classes"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="jar"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">mkdir&nbsp;</span><span style="color: #ff0000">dir</span><span style="color: #0000ff">="build/jar"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">jar&nbsp;</span><span style="color: #ff0000">destfile</span><span style="color: #0000ff">="build/jar/HelloWorld.jar"</span><span style="color: #ff0000">&nbsp;basedir</span><span style="color: #0000ff">="build/classes"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">manifest</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">attribute&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="Main-Class"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="oata.HelloWorld"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">manifest</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">jar</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="run"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">java&nbsp;</span><span style="color: #ff0000">jar</span><span style="color: #0000ff">="build/jar/HelloWorld.jar"</span><span style="color: #ff0000">&nbsp;fork</span><span style="color: #0000ff">="true"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">project</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
</span></div>
<br />
2.运行：<br />
ant compile<br />
ant jar<br />
ant run<br />
看到结果<br />
<br />
注意：要在系统环境里面设置PATH到ant的bin目录<br />
<br />
3.更加简便的打包：修改build.xml，为：<br />
<div style="border-right: #cccccc 1px solid; padding-right: 5px; border-top: #cccccc 1px solid; padding-left: 4px; font-size: 13px; padding-bottom: 4px; border-left: #cccccc 1px solid; width: 98%; word-break: break-all; padding-top: 4px; border-bottom: #cccccc 1px solid; background-color: #eeeeee"><span style="color: #0000ff">&lt;</span><span style="color: #800000">project&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="HelloWorld"</span><span style="color: #ff0000">&nbsp;basedir</span><span style="color: #0000ff">="."</span><span style="color: #ff0000">&nbsp;default</span><span style="color: #0000ff">="main"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="src.dir"</span><span style="color: #ff0000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value</span><span style="color: #0000ff">="src"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="build.dir"</span><span style="color: #ff0000">&nbsp;&nbsp;&nbsp;value</span><span style="color: #0000ff">="build"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="classes.dir"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="${build.dir}/classes"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="jar.dir"</span><span style="color: #ff0000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value</span><span style="color: #0000ff">="${build.dir}/jar"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">property&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="main-class"</span><span style="color: #ff0000">&nbsp;&nbsp;value</span><span style="color: #0000ff">="oata.HelloWorld"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
<br />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="clean"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">delete&nbsp;</span><span style="color: #ff0000">dir</span><span style="color: #0000ff">="${build.dir}"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="compile"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">mkdir&nbsp;</span><span style="color: #ff0000">dir</span><span style="color: #0000ff">="${classes.dir}"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">javac&nbsp;</span><span style="color: #ff0000">srcdir</span><span style="color: #0000ff">="${src.dir}"</span><span style="color: #ff0000">&nbsp;destdir</span><span style="color: #0000ff">="${classes.dir}"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="jar"</span><span style="color: #ff0000">&nbsp;depends</span><span style="color: #0000ff">="compile"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">mkdir&nbsp;</span><span style="color: #ff0000">dir</span><span style="color: #0000ff">="${jar.dir}"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">jar&nbsp;</span><span style="color: #ff0000">destfile</span><span style="color: #0000ff">="${jar.dir}/${ant.project.name}.jar"</span><span style="color: #ff0000">&nbsp;basedir</span><span style="color: #0000ff">="${classes.dir}"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">manifest</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">attribute&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="Main-Class"</span><span style="color: #ff0000">&nbsp;value</span><span style="color: #0000ff">="${main-class}"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">manifest</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">jar</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="run"</span><span style="color: #ff0000">&nbsp;depends</span><span style="color: #0000ff">="jar"</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">java&nbsp;</span><span style="color: #ff0000">jar</span><span style="color: #0000ff">="${jar.dir}/${ant.project.name}.jar"</span><span style="color: #ff0000">&nbsp;fork</span><span style="color: #0000ff">="true"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">target</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="clean-build"</span><span style="color: #ff0000">&nbsp;depends</span><span style="color: #0000ff">="clean,jar"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000ff">&lt;</span><span style="color: #800000">target&nbsp;</span><span style="color: #ff0000">name</span><span style="color: #0000ff">="main"</span><span style="color: #ff0000">&nbsp;depends</span><span style="color: #0000ff">="clean,run"</span><span style="color: #0000ff">/&gt;</span><span style="color: #000000"><br />
<br />
</span><span style="color: #0000ff">&lt;/</span><span style="color: #800000">project</span><span style="color: #0000ff">&gt;</span><span style="color: #000000"><br />
</span></div>
<img src ="http://www.blogjava.net/pixysoft/aggbug/244339.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/pixysoft/" target="_blank">张辰</a> 2008-12-04 11:50 <a href="http://www.blogjava.net/pixysoft/archive/2008/12/04/244339.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>