愛上鳥的魚

          無憂無慮害死人

          常用鏈接

          統計

          最新評論

          2008年1月14日 #

          java 環境變量 classpath的使用

          最近,使用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?結構
          1handwork
          bin
          src?
          myPro
          TestString.java
          當前目錄為\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

          posted @ 2008-01-14 11:35 愛上鳥的魚| 編輯 收藏

          僅列出標題  
          主站蜘蛛池模板: 卢湾区| 同心县| 雅安市| 南部县| 清水河县| 林甸县| 邓州市| 尼玛县| 张家界市| 琼海市| 郴州市| 黎川县| 定陶县| 睢宁县| 宁晋县| 洱源县| 博罗县| 大同县| 安岳县| 永济市| 罗甸县| 松桃| 庆云县| 宜良县| 探索| 高唐县| 青川县| 石阡县| 江口县| 绥德县| 青龙| 丽水市| 阳新县| 钦州市| 清远市| 沙洋县| 乌海市| 屏边| 文昌市| 阜宁县| 鄂伦春自治旗|