This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
to compile option A is correct OK, then you need to run ...
now your question is why option D is incorrect.
from oracle documents:
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.
I strongly suggest you to compile as in option A then analyze the output ;)
Hi Ankit Buddy,
java -cp pack.jar means java will search through the directories inside pack.jar to look for pack.client.Client. But this Client class is not in jar. The directory pack/client/Client is under $ROOT directory. Java needs to search $ROOT directory to find pack.client.Client.
Instead of D, G will work because java -cp .:pack.jar includes the current directory $ROOT.
Thanks Seetharaman and Himay for your very helpful reply..
so what i understand is , when we want to run the class file, at that time we need that class file and the related class file that used by it.
so in this case, If i run with command "java -cp . pack.client.Client" that will not run because it can't find the bank class.