I've experimented with various javac
command line examples, and I can now answer my own question:
If any source code dependency files are edited, then either of these two javac
variations will recompile them:
javac -sourcepath src -cp bin -d bin src\pkgs\main\Main.java
javac -sourcepath src -d bin src\pkgs\main\Main.java
However, the following javac
variation will not recompile edited source code dependency files:
javac -cp bin -d bin src\pkgs\main\Main.java
Please note that in all three of the javac
variations above, the Main.class
file is always regenerated. In my original question, I wondered if it was possible for automatic recompilation to not occur, if javac
excluded the use of -cp
(-classpath
). I don't think that is possible, because if javac
was not told about the location of .class
files, it would have be told about the location of source files, and once found, it would then have to recompile them, in order to create the required .class
files for the project!