在服务器上没必要去装eclipse,用ant非常方便快速
http://ant.apache.org/bindownload.cgi
在里面找东东,对于绿色版的东东,除了自己做的和官网发表的,其他都一概别下,会有病毒或者垃圾文件
的.
ant的配法:
1。解压ant的包到本地目录。
2。在环境变量中设置ANT_HOME,值为你的安装目录。
3。在环境变量中设置JAVA_HOME,值为你的jdk安装目录。
4。把ANT_HOME/bin加到你系统的path目录中去。
SET ANT_HOME=D:/apache-ant-1.8.1 //知道home目录都是根目录吧,类似于java_home...
SET PATH=%PATH%;%ANT_HOME%/bin;
在cmd模式下输入 ant -version回车,看到输出说明配置成功。
然后是配置build.xml啦,这里只说编译,有其他问题留言就行,我会关注的:
建一个build.xml,最好在你的项目里的根目录下
<?xml version="1.0" encoding="UTF-8" ?>
<project name="MobileBank" default="compile" basedir=".">
<property name="src" value="src"/>
<property name="dest" value="class"/> <!--class文件在哪里就放在哪里-->
<target name="init">
<mkdir dir="${dest}"/>
</target>
<target name="compile" depends="init"> <!-- 编译-->
<javac srcdir="${src}" destdir="${dest}" includeantruntime="on"/>
</target>
<!--<target name="build" depends="compile"> 打包
<jar jarfile="${hello_jar}" basedir="${dest}"/>
</target>
<target name="run" depends="build"> 运行
<java classname="test.ant.HelloWorld" classpath="${hello_jar}"/>
</target>
-->
<!--<target name="clean"> 删除生成的文件
<delete dir="${dest}" />
<delete file="${hello_jar}" />
</target>
<target name="rerun" depends="clean,run"> 再次运行
<ant target="clean" />
<ant target="run" />
</target>
-->
</project>
然后在cmd模式下,转到build的目录.输入ant,回车
不说别的,在编译的时候:
<target name="compile" depends="init">
<javac srcdir="${src}" destdir="${dest}" includeantruntime="on"/> <!--
includeantruntime="on" 一定要加上 -->
</target>
然后就是软件包引用的问题了,全部copy到jre的lib里的ext包中.
之后做成绿色版,
将ant文件夹复制到项目的根目录(项目需要的jar包事先要copy到jre/lib/ext中),然后写一个bat文件,
内容
SET ANT_HOME=%cd%/apache-ant-1.8.1
SET PATH=%PATH%;%ANT_HOME%/bin;
ant
在非服务器机器上,一般都有eclipse或者myeclipse,是自动编译的.如果比较性能的话,删掉eclipse自动
编译的class文件,300个类,eclipse重新完整的一次性编译要20分钟,而ant只要10秒!!!
搞定,收工!