愛上鳥的魚

          無憂無慮害死人

          常用鏈接

          統(tǒng)計(jì)

          最新評論

          2008年1月14日 #

          java 環(huán)境變量 classpath的使用

          最近,使用eclipse是速度很慢,于是在找到了原始的編譯、運(yùn)行程序的方法?:使用javac和java

          java -classpath %classpath%;g:\javaPro\proName\webroot\web-inf\lib\db2jcc.jar;bin? myPro.Test

          %classpath%? 為系統(tǒng)已經(jīng)設(shè)置的環(huán)境變量
          ?g:\javaPro\proName\webroot\web-inf\lib\db2jcc.jar 為運(yùn)行myPro.Test類運(yùn)行時(shí)涉及到的類文件
          bin 為myPro.Test 存放的目錄
          這樣,編譯和運(yùn)行程序就能比較快一些了。
          handwork?結(jié)構(gòu)
          1handwork
          bin
          src?
          myPro
          TestString.java
          當(dāng)前目錄為\src>? javac myPro\TestString.java -d ..\bin
          這樣編譯的文件會存放在bin目錄下。
          \bin>javap -c myPro.TestString 可以看到編譯后的類文件.


          第二種快速編譯和 運(yùn)行的 方法使用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 愛上鳥的魚| 編輯 收藏

          僅列出標(biāo)題  
          主站蜘蛛池模板: 平度市| 通道| 金秀| 南郑县| 武隆县| 吉林省| 安顺市| 泰安市| 旺苍县| 美姑县| 高阳县| 陇西县| 武强县| 民和| 海原县| 北宁市| 锦州市| 娱乐| 峨眉山市| 云安县| 勃利县| 五峰| 资兴市| 定兴县| 东明县| 探索| 双峰县| 江源县| 宁都县| 通海县| 屏东县| 土默特右旗| 科技| 临汾市| 新郑市| 金乡县| 饶平县| 衡阳市| 简阳市| 自贡市| 金溪县|