开发者

Java Command Line Compilation Problems and Dependecies

I have the following class structure:

Main Class: WordNet.java
WordNet.java uses SAP.java
SAP.java uses DeluxeBFS.java

When I run the command

$ javac WordNet.java

I get back

WordNet.class
WordNet$Synset.class
SAP.class
DeluxeBFS.class
DeluxeBFS$markDist.class

Synset and markDist are private classes.

What I don't understand though, is why if I make a change in DeluxeBFS, and 开发者_C百科recompile WordNet, that change is not compiled in. Since WordNet depends on DeluxeBFS, shouldn't the java compiler recompile it if a change is made? It seems like the file is not even touched.


No, the compiler finds the class file for DeluxeBFS, and that's the end of it - it doesn't try to look for the source for it (which could be anywhere of course).

In general, it's a good idea to recompile everything when you're building from the command line with javac.

If you want incremental compilation which notices which files have been changed etc, you should use something an IDE like Eclipse.


You answered your own question - javac won't recompile all dependencies, only the files given as input. This is actually an advantage - IDEs like Eclipse will only compile the modified files rather than the whole codebase

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜