themaestro
themaestro

Reputation: 14256

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 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.

Upvotes: 1

Views: 220

Answers (2)

Lucas Zamboulis
Lucas Zamboulis

Reputation: 2543

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

Upvotes: 1

Jon Skeet
Jon Skeet

Reputation: 1499840

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.

Upvotes: 1

Related Questions