一个比较搞的应用
用jar来调用工程目录下的class文件运行,
比较复杂,用ant跑的
现在在调用的地方出了问题工程目录,当然上面还有路径
/Tools/core/libs/tool.jar
/Tools/apache-ant-1.6.5/
/Tools/TestProject/work/a/A.java
/Tools/TestProject/work/b/B.java
/Tools/TestProject/build.xmlA.java是package A的
B.java是package B的
已经编译好了在/Tools/TestProject下运行ant命令:
../apache-ant-1.6.5/bin/ant execuate -Dparam.class=b.B <target name="execuate">
<java jar="..\core\libs\tool.jar" fork="true">
<classpath>
· <fileset dir="work\a">
<include name="**/*" />
</fileset>
<fileset dir="work\b">
<include name="**/*" />
</fileset>
<pathelement location="..\core\libs\tool.jar" />
</classpath>
<arg value="${param.class}" />
</java>
</target>
ant会运行tool.jar,想在里面用Class.forName("b.B")来读取B.class
现在一直出java.lang.ClassNotFoundException: b.B这个classpath该怎么定义,才能让work\a和work\b下面的class文件能够load到?
用jar来调用工程目录下的class文件运行,
比较复杂,用ant跑的
现在在调用的地方出了问题工程目录,当然上面还有路径
/Tools/core/libs/tool.jar
/Tools/apache-ant-1.6.5/
/Tools/TestProject/work/a/A.java
/Tools/TestProject/work/b/B.java
/Tools/TestProject/build.xmlA.java是package A的
B.java是package B的
已经编译好了在/Tools/TestProject下运行ant命令:
../apache-ant-1.6.5/bin/ant execuate -Dparam.class=b.B <target name="execuate">
<java jar="..\core\libs\tool.jar" fork="true">
<classpath>
· <fileset dir="work\a">
<include name="**/*" />
</fileset>
<fileset dir="work\b">
<include name="**/*" />
</fileset>
<pathelement location="..\core\libs\tool.jar" />
</classpath>
<arg value="${param.class}" />
</java>
</target>
ant会运行tool.jar,想在里面用Class.forName("b.B")来读取B.class
现在一直出java.lang.ClassNotFoundException: b.B这个classpath该怎么定义,才能让work\a和work\b下面的class文件能够load到?
<fileset dir="work" includes="**/*.class"/>
这个试过了,还是ClassNotFoundException
这个就是把fileset的include写到标签里了吧
<pathelement location="work"/>
就这样吧