[英]Use javac only sitting in the root of the source tree? What does it mean?
I have a professor who always insists on 我有一个教授总是坚持
"sitting in the root of the source tree when invokingjavac
(and in the root of the directory when invokingjava
)". “调用javac
时坐在源树的根目录中(调用java
时坐在目录的根目录中”)。
Although, for the basic programs I have done, I have never found the need of doing that. 尽管对于我已经完成的基本程序,我从未发现需要这样做。
So, what is the need of doing it? 那么,有什么需要做的呢?
It means that if you have a package, foo
, and a class or classes in that package: 这意味着如果您有一个包foo
和该包中的一个或多个类:
package foo;
class Nifty {
// ...
}
...and your source tree looks like (and it mostly has to): ...并且您的源代码树看起来像(并且大多数情况下是这样):
+ source + foo + Nifty.java
javac
will expect to be in the source
directory when you're compiling, not in the foo
directory. javac
应该位于source
目录中,而不是foo
目录中。 It's just how javac
is. 这就是javac
。
java
will expect that the classpath will include source
(not foo
), and like javac
work relative to that (looking in foo
for the classes in the package foo
). java
希望classpath包含source
(不是foo
),并且像javac
一样相对于source
(在foo
查找包foo
的类)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.