我一直在使用这么多的第三方库(jar文件),我的CLASSPATH完全搞砸了,因为我必须包含我使用的每个jar文件的路径.
我一直想知道是否有办法使用通配符(*)运算符(如*.jar)将所有jar文件包含在文件夹中.但似乎没有用.有没有其他方法可以缩短当前看起来像文章的CLASSPATH;)在我的电脑上?
如何配置项目构建路径以使一组位于同一目录中的.jar文件自动包含在构建路径中?这意味着将新的.jar文件添加到此目录(并刷新项目)会更新构建路径?Rem:我不是在Web应用程序中工作,而是在独立的Java应用程序中工作.我知道在Dynamic Web Project中可以将WEB-INF/lib中的所有.jars包含在构建路径中.是否可以在独立应用程序中执行相同的包含?
我正在使用Eclipse 3.4
我有一个build.xml,允许我运行junit测试.以下是相关部分:
<path id="JUnit 4.libraryclasspath">
<pathelement location="../../../../../eclipse/plugins/org.junit4_4.5.0.v20090824/junit.jar"/>
<pathelement location="../../../../../eclipse/plugins/org.hamcrest.core_1.1.0.v20090501071000.jar"/>
</path>
<path id="MyProject.classpath">
<pathelement location="bin"/>
<path refid="JUnit 4.libraryclasspath"/>
</path>
<target name="run_unit_tests" depends="build">
<mkdir dir="${junit.output.dir}"/>
<junit printsummary="yes" haltonfailure="no">
<classpath refid="MyProject.classpath" />
<formatter type="xml"/>
<batchtest todir="${junit.output.dir}">
<fileset dir="${src}">
<include name="**/*Test*.java"/>
</fileset>
</batchtest>
</junit>
</target>
Run Code Online (Sandbox Code Playgroud)
如果我更换线路:
<pathelement location="../../../../../eclipse/plugins/org.junit4_4.5.0.v20090824/junit.jar"/>
Run Code Online (Sandbox Code Playgroud)
同
<pathelement location="${eclipse.home}/plugins/org.junit4_4.5.0.v20090824/junit.jar"/>
Run Code Online (Sandbox Code Playgroud)
更改打破了类路径.我收到以下错误:
该
<classpath>
用于<junit>
如果不是在Ant的自己的类路径必须包含的junit.jar
据我所知,location属性在两种情况下都应该保持相同的值.那可能是什么原因呢?
作为一个附带问题,此构建文件不适用于具有不同junit版本的环境(路径将中断).是否可以为junit.jar添加"常规"路径?