将一个简单的类(Sample)进行编译打包运行(传参数)
源文件java源文件Samplejava
package powerwind;
import javaxswing*;
public class Sample {
public static void main(String[] args) throws Exception {
if (argslength > )
JOptionPaneshowMessageDialog(null args[]);
else
JOptionPaneshowMessageDialog(null HelloWorld);
}
}
ant文件buildxml
注意encoding=GBK 设置后才可以有中文注释
<?xml version= encoding=GBK ?>
<! ===================================== >
<! 周健兴 // >
<! ===================================== >
<project name=sample default=run basedir=>
<description>用于学习的简单ant工程文件</description>
<!属性设置>
<property environment=env />
<property file=buildproperties />
<property name=srcdir value=${basedir}/src />
<property name=javalibdir value=${envJAVA_HOME}/lib />
<property name=builddir value=${basedir}/build />
<property name=classesdir value=${builddir}/classes />
<property name=distdir value=${basedir}/dist />
<! 基本编译路径设置 >
<path id=compileclasspath>
<fileset dir=${javalibdir}>
<include name=toolsjar />
</fileset>
</path>
[] [] [] []