Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ant javac returning message "A.java added as A.class doesn't exist"

Tags:

java

ant

I'm writing an ANT task that is behaving very oddly. I've tried a variety of google searches with no clear answer.

I have a compile target in ANT that calls the javac command:

<target name="compile">
    <mkdir dir="${classes.dir}" />
    <javac srcdir="${src.dir}:${unittest.src.dir}" destdir="${classes.dir}">
        <classpath refid="classpath" />
        <exclude name="**/plugins/**" />
        <exclude name="**/outbound/**" />
    </javac>
</target>

That generates no errors, but when I run ant with the -verbose and -debug tags I get the following in my logs:

[javac] package/MyClass.java added as package/MyClass.class doesn't exist

So it's not erroring out, but it is giving me this odd result (with the "doesn't exist" appended at the end). Obviously this causes later targets to fail when it tries to run the classes (in this case, my junit target).

Web searches seem to indicate that I'm either missing a java_home env variable or that there is a versioning issue somewhere along the line (this error tended to occur when the source attribute on javac was set, but I removed that and am still getting the odd result). I believe we've got those possibilities covered.

Any thoughts or advice on this would be wonderful. Thanks.

like image 248
Riggy Avatar asked Oct 13 '22 19:10

Riggy


1 Answers

I don't know too much about ant, but I would almost guess this error message is a red herring. I think it's just reporting that MyClass.java was added to the list of files to compile, because the compiled version of the class was not found on the class path. This seems to be supported by the fact that the task does not fail.

What are the later errors you are getting?

like image 98
Mark Peters Avatar answered Oct 18 '22 06:10

Mark Peters