This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
javac -d bin -sourcepath src
i understand that -sourcepath option is for locating source file and that those source files referenced directly or indireclty by MainFrame.java(the file i'm compiling) will be compiled and put into the argument specified by -d option. what i don't understand is why we are using -classpath option here. what it does ? because we use -classpath option when we are invoking JVM using java from command-line.
gurpeet singh wrote:what i don't understand is why we are using -classpath option here. what it does ? because we use -classpath option when we are invoking JVM using java from command-line.
Yes, you are right that we use -classpath option while running the class file, but that doesn't mean that the option -classpath cannot be used during compilation.
Consider below scenario:
You are using some junit classes in one of your source files. Then, how java compiler (javac) would know that what this class is, and where the class file for this class is located and what are the methods and arguments and so on? Of course the -classpath option!