Hi everyone,
When I’m building a simple project with ANT 1.8.2, I encountered a compiling error at the
import statement of the java code file.
There only 2 java files: A.java and com/B.java.
A.java is in the root dir of the source directory, it has a public static method test() that
B.java will call;
B.java is in the package com, it calls A.test() from inside, with ‘import A;’
at the beginning following ‘package com;’.
When I wrote a build.xml and added a <javac> task in it to compile the java
codes, there appeared a compiling error at the ‘import’ statement ---- ‘.’ needed
---- seems that can’t import the class at the root of the source directory in JAVA.
But it runs well when I put the codes in Eclipse. And I tried all the attributes
of the javac task but still didn’t work. I don’t know why.
Anyone faced the similar problem? How did you solve this?
Any suggestions would be highly appreciated!
The Eclipse project’s Java compiler setting is like this:
And I set the javac task’s source=”1.3” and target=”1.1”:
<javac source="1.3" target="1.1" srcdir="src" destdir="class"/>
Will get the same error.