繁体   English   中英

即使Javac Ant任务包含在类路径中,也无法找到它

[英]Javac Ant task can't find a class even though it is contained in the classpath

我的javac Ant任务产生如下所示的错误:

[javac] C:\dp\dev\trunk\MyProduct\MyUnitTest.java:109: error: cannot find symbol
[javac]     private MyClass createFactoryMock() throws Exception {
[javac]             ^
[javac]   symbol:   class MyClass
[javac]   location: class MyUnitTest

我以详细模式( ant -verbose test-compile )运行任务,并在任务的类路径输出中找到MyClass ,由此得出的结论是, MyClass存在于类路径中。

[javac] Compiling 9 source files to C:\dp\dev\trunk\MyProduct\temp\test-build

[javac] Using modern compiler
[javac] Compilation arguments:
[javac] '-d'
[javac] 'C:\dp\dev\trunk\MyProduct\temp\test-build'
[javac] '-classpath'
[javac] '[...]C:\dp\dev\trunk\MyProduct\temp\build\MyProduct\MyClass.class[...]

除了类路径问题,还有什么其他原因可能导致错误?

我通过更改解决了问题

    <javac srcdir="${test}" destdir="temp/test-build" debug="${debug}" encoding="UTF-8">
        <classpath>
            [...]
            <fileset dir="${build}"/>
        </classpath>
    </javac>

    <javac srcdir="${test}" destdir="temp/test-build" debug="${debug}" encoding="UTF-8">
        <classpath>
            [...]
            <pathelement location="${build}"/>
        </classpath>
    </javac>

使其指向存在jar的确切jar文件目录:

<path id="classpath">
    <fileset dir="${main.jar}" includes="**/*.jar"/>
    <!-- <pathelement location="${src.dir}" />-->
</path>

----就我而言,jar文件位于----

<property name="main.jar" value="jar"/>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM