0
<project name="MyProject" default="run" basedir=".">
<description>
simple example build file
</description>
<!-- set global properties for this build -->
<property name="src" location="./src"/>
<property name="build" location="./build"/>
<property name="lib" location="./lib"/>
<property name="zmq.dir" location="/usr/local/share/java"/>
<path id="classpath.compile">
<fileset dir="${lib}">
<include name="**/*.jar"/>
</fileset>
<pathelement location="${zmq.dir}/zmq.jar"/>
</path>
<path id="classpath.run">
<path refid="classpath.compile"/>
<fileset dir="${build}/classes">
<include name="**/*.class"/>
</fileset>
</path>
<target name="clean"
description="clean up" >
<delete dir="${build}"/>
</target>
<target name="init" depends="clean">
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
<mkdir dir="${build}/classes"/>
</target>
<target name="compile" depends="init"
description="compile the source " >
<property name="compile.classpath" refid="classpath.compile"/>
<echo message="Compiling with classpath ${compile.classpath}"/>
<javac srcdir="${src}"
destdir="${build}/classes">
<classpath refid="classpath.compile"/>
</javac>
</target>
<target name="run" depends="compile">
<property name="run.classpath" refid="classpath.run"/>
<echo message="Running with classpath ${run.classpath}"/>
<java fork="true"
dir="${build}/classes"
classname="jgf.EMDR_Client"
classpathref="classpath.run"/>
</target>
</project>
當我運行該項目給java.lang.ClassNotFoundException: jgf.EMDR_Client
Ant腳本給類沒有發現異常 - 爲什麼?
我附和類路徑編譯和運行
編譯是:
/Users/JGF/Projects/emdr/lib/json_simple-1.1.jar:/usr/local/share/java/zmq.jar
運行是:
/Users/JGF/Projects/emdr/lib/json_simple-1.1.jar:/usr/local/share/java/zmq.jar:/Users/JGF/Projects/emdr/build/classes/jgf/EMDR_Client.class
我JAVA_HOME是:/Library/Java/Home
是ant java dir attribute borked?
我修改劇本,拿出參考classpath.run,只是直接引用classpath.lib。仍然沒有歡樂......沒有使用類路徑標記 - 而是java任務的classpathref屬性,儘管如此...仍然沒有喜悅。 – JGFMK
已修改的java任務和embeddd類路徑標記而不是屬性。那也行不通。相同的舊類沒有發現異常。 – JGFMK
我會補充一點,zmq.jar是一個奇怪的野獸 - ZeroMQ項目的一部分 - 我相信它只是一個JNI包裝本地類,我用它在我的Mac上運行。這不可能是一個奇怪的原因,這個班不被發現嗎? - 它在build/classes目錄中,你可以從屏幕截圖 – JGFMK