最近,使用eclipse是速度很慢,于是在找到了原始的編譯、運行程序的方法?:使用javac和java
java -classpath %classpath%;g:\javaPro\proName\webroot\web-inf\lib\db2jcc.jar;bin? myPro.Test
%classpath%? 為系統已經設置的環境變量
?g:\javaPro\proName\webroot\web-inf\lib\db2jcc.jar 為運行myPro.Test類運行時涉及到的類文件
bin 為myPro.Test 存放的目錄
這樣,編譯和運行程序就能比較快一些了。
handwork?結構
當前目錄為\src>? javac myPro\TestString.java -d ..\bin
這樣編譯的文件會存放在bin目錄下。
\bin>javap -c myPro.TestString 可以看到編譯后的類文件.
第二種快速編譯和 運行的 方法使用ant工具 配置的 build.xml文件如下:
<?xml version="1.0"?>
<project name="zxfTest" default="run">
? <!--the position of class by compiled-->
??<property name="class.dir" value="bin"/>
??<!--source position-->
?? <property name="src.dir" value="src"/>
?? <!--reference class path -->
?<path id="1">
?<fileset dir="g:\javaPro\pwms\webroot\web-inf\lib">
?<include name="db2jcc.jar"/>
?</fileset>
?</path>
?<!-- compile java file-->
?? <target name="compile" >
?<javac srcdir="${src.dir}" destdir="${class.dir}">
?<!--? will be use by compile -->
?<classpath refid="1"/>
?</javac>
?<!-- copy the class file to the destination-->
?<copy todir="${class.dir}">
?<!-- need compile file -->
?<fileset dir="${src.dir}">
?? <exclude name="**/*.java"/>
?</fileset>
?</copy>
</target>
<target name="run">
<java classname="zxf.Test">
??<classpath path="${class.dir}">
??</classpath>
??<classpath refid="1"/>
</java>
</target>
</project>
在path中 需要配置ant的path? %ant_home%\bin