"I'm not back." - Bill Harding, Twister
This is (in my mind) bad behaviour. Because let's say all my source files are in the same directory. If I import a certain class, and the source for that imported class is in the current directory, then that *.java would get turned into a *.class, and then THAT (improperly placed because I don't use -d) *.class file would be used.<pre>javac - classpath . TestReplacePackage.java</pre>
you are telling the compiler to comile that particular file, and any other files it needs to in order to have all the necessary class files.
Key point here - if there is a .class file or .jar file with the appropriate class and a .java file, the compiler does not check dates to see if the .java is newer than the .class, indicating it should recompile. Instead it will simply use the old .class file. I'm not sure if it always uses a class file if available, or if it uses whichever it finds first. I think it's the latter, but you should test to see. This sort of thing can vary from compiler to compiler anyway, I believe.
In my case, it seems that finding the *.java file before the *.class file was the whole problem. It was the fact that my imported class's source file was in the classpath. But I see what you mean. If I used -d, the recompiled (completely unnecessarily) class file would be moved before the importing class is compiled. But I still don't like the behaviour of recompiling the imported classes. It should attempt the import first, and it would find the right class file ready and waiting for it, and not need to recompile the *.java source. ie: Note to Sun: compile *only* what I tell you to compile.I recommend you compile using the -d option to put executables in a separate directory tree from the source code. Then you can tune your class path to make sure that the compiler finds .java files before .class files.
"I'm not back." - Bill Harding, Twister