
附:你的classpath 配置有问题。
在jdk5,6中,默认已经包含了.指向%java_home%\bin是没有意义的。要指向也是%java_home%\lib\tools.jar
下载安装下载
需要设置的环境变量
ANT_HOME ant的安装目录
JAVA_HOME jdk的安装目录
PATH 把%ANT_HOME%\bin目录加到path变量 以便于从命令行下直接运行ant
假定ant解压在c \ant jdk装d \j sdk
则在命令行下执行以下命令
set ANT_HOME=c:\antset JAVA_HOME=D:\j sdk set PATH=%PATH%c:\ant\bin
一个ant 工程目录结构
C \workspace\ant test 工程主目录
\src 源程序目录
\build\classes 编译后的 class 文件目录
\lib 开发工程所需要的类库目录 比如开发数据库时所需要的 jdbc lib(这次没用到)
\jar 打包好的 jar 程序目录(这次没用到)
\build xml 工程配置文件\build propertiees 工程资源文件
建立工程描述文件和建立工程资源文件
建立工程描述文件build xml
<?xml version= ?><project default= main basedir= > <echo message= pulling in property files /> <property file= build properties /> <target name= init > <echo message= init delete the old class files and create the new folds /> <delete dir= ${classpath} /> <mkdir dir= ${classpath} /> </target> <target name= pile depends= init > <echo message= pile the java source files /> <javac srcdir= src\hello\ant destdir= ${classpath} /> </target> <target name= main depends= pile > <echo message= calling java to run this java project /> <java classname= hello ant HelloAnt > <classpath> <pathelement path= ${classpath} /> </classpath> </java> </target></project>
建立工程资源文件 build properties
文件内容是下面一行内容
classpath=build\\classes
建立java源文件 hello ant HelloAnt java
package hello antpublic class HelloAnt { public static void main(String[] args) { System out println( hello ant the first time using ant it is great ) }}
编译
lishixinzhi/Article/program/Java/ky/201311/28515
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)