When searching for class files, the java and javac commands don't search the current directory by default
As long as I don't set a classpath using the -cp command that is not true on my machine. For example: the command "javac dir1\dir2\Father.java" works just fine, if the Father.java file needs a class-file that is in the current directory.
Does that always work? So, given the above scenario and a question in the exam, asking whether this command will compile the Father.java-file, will "compilation succeeds" be the correct answer? [ May 18, 2007: Message edited by: Sasha Ruehmkorf ]
Hi Satou. If I change to dir2 and then invoking your command, compilation will fail, of course. In this case I need to type "javac -cp ..\.. Father.java", so that the compiler will find the class-files needed.
But will the given command in the given scenario in my first post always work? (at least it does on my machine)
nik, what exactly is it, that you don't understand? [ May 18, 2007: Message edited by: Sasha Ruehmkorf ]
The default class path is the current directory. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings.