Hi all:
I encountered a very confusing problem when using javac.
Now I have a class Test.java, which belongs to the package "test", see the source code below:
package test;
public class Test {
public static void main(String[] args) {
System.out.println("test success!");
}
}
My test folder archive:
tmp/--
src/--test/--Test.java
|
build.xml
The compile target in build.xml is:
<target name="compile" depends="init">
<javac destdir="classes">
<src path="src"/>
</javac>
</target>
Now I am under the base directory(~/*/tmp/$), when run ant in the terminal there is no doubt that the ant will successfully build my class "Test.java" into the folder classes.
It's known to all that "src" in ant is used to set the -sourcepath option used by "javac". However, when I directly use javac in terminal(still under the base directory) by setting the -sourcepath options, the compiler tell me it cannot find my class. See below for details:
wxiong@earth:~/workspace/tmp$ ls -a
*. .. build.xml src*
wxiong@earth:~/workspace/tmp$ ls -a src
*. .. test*
wxiong@earth:~/workspace/tmp$ ls -a src/test
*. .. Test.java*
*//above is my workspace info, and below I run the "javac"*
wxiong@earth:~/workspace/tmp$ javac -sourcepath src test/Test.java
javac: file not found: test/Test.java
Usage: javac <options> <source files>
use -help for a list of possible options