Given that the MusicPlayer project is on a Unix system and consists of the following files
/mp/classes/MusicPlayer.java
/mp/classes/player/MusicPlayer.class
/mp/jars/mp.jar
Inside mp.jar file structure is
player/MusicPlayer.java
player/MusicPlayer.class
you are currently in the directory
/mp
and the CLASSPATH is set to
/mp/jars
What command(s) can you use to invoke the class player MusicPlayer?
Correct Answer:
A.
java -cp classes player.MusicPlayer
B. java -cp /mp/jars/mp.jar player.MusicPlayer
According to the K&B book Pg 768
"When searching for class files, the java and javac commands don't search the current directory by default.
Then how can answer A be correct?
According to what I understand the answer should be
java -cp classes/Player Player.MusicPlayer
because with this command the classes directory will not be searched where as Player will be searched and there we find the required .class file.
Can anyone please explain. I find similar questions in K&B which are really confusing me.