0

ソース ファイルがパッケージの一部であり、ソース ツリーのディレクトリ構造がパッケージ階層に従っていない場合、javac antタスクは Java クラスをコンパイルできません。ただし、別のマシンでも同じことがわかります

build.xml

ファイルは正常に実行されます。

たとえば、パッケージを含む Java ファイルがありcom.abc.myapp.server.base、ソース ファイルがC:\mySource\baseフォルダーの下にある場合、javacこのクラスをコンパイルできません。ただし、.javaソースファイルをC:\mySource\com\abc\myapp\server\baseフォルダーの下に移動すると、すべてうまくいきます。

Windows 7でANT 1.8.0バージョンとJDK 1.7.0_17バージョンを使用しています。

お知らせ下さい

4

1 に答える 1

0

It sounds like you're not setting up your directory structure to match the packages of your java source files. The source for the class "org.example.abc.HelloWorld" should live in a directory like /src/org/example/abc.

Typically, you'd want your build.xml to be at the top-level of whatever project you're trying to build, and then the javac task inside it can reference the source directory where your package structure starts.

Something like this:

<project name="example" default="compile">
    <target name="compile" description="compiles">
        <mkdir dir="build"/>
        <javac srcdir="src" destdir="build"/>
    </target>
</project>

This is obviously very over simplified, but should help get you started.

If you're still having trouble, post your build.xml and some description of your project's layout so we can help.

于 2013-03-19T14:35:53.840 に答える