aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Question classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "Question classpath" Watch "Question classpath" New topic
Author

Question classpath

Vinicius Moreira
Greenhorn

Joined: Jan 18, 2010
Posts: 26
Hi Friends,
Question from masterexam

I could not understand why E and H are the correct alternatives, if someone can give me a strength in that part of the classpath would be grateful, is the subject which will enable me to be ready for scjp
Sorry bad grammar because I'm from Brazil
Thanks
Ankit Garg
Saloon Keeper

Joined: Aug 03, 2008
Posts: 9189
    
    2

Hi Vinicius, welcome to javaranch.

Option H has a mistake in it, /mp/jars/cp.jar should be /mp/jars/mp.jar. Classpath is explained here...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Vinicius Moreira
Greenhorn

Joined: Jan 18, 2010
Posts: 26
Thanks Ankit Garg for answer
I'm reading the link you gave me but still do not understand how it works right, is the subject remaining to complete my studies for the test scjp
Thanks for answer
Juliet Smith
Greenhorn

Joined: Apr 12, 2010
Posts: 3
I agree that H contains a mistake, but not with Ankits reply (the jar filename is correctly shown in option H as mp.jar and not cp.jar as he states)

I think H should read java -cp /jars/mp.jar player.MusicPlayer

(The question states "You are currently in the directory /mp")

Prithvi Sehgal
Ranch Hand

Joined: Oct 13, 2009
Posts: 771
Hello Juliet,

Welcome to Javaranch.

Happy Preparation,


Prithvi/Beenish,
My Blog, Follow me on Twitter,Scjp Tips, When you score low in mocks, Generics,Scjp Notes, JavaStudyGroup
Kaspar Christenson
Greenhorn

Joined: Feb 26, 2009
Posts: 21

Since you're on a UNIX system
java -cp /jars/mp.jar player.MusicPlayer
would look for the jars directory under the root folder.
You need to get ride of the forward slash before jar to get this command line to work.


It helps to understand the classpath if you remember that for the .class files it is enough to give the path to the directory that contains the directory with the same name as the first part of the package declaration.

To use a JAR file you have to give it the name of the file. Giving it the name of the directory containing the JAR file will not work.
Juliet Smith
Greenhorn

Joined: Apr 12, 2010
Posts: 3
So H should read:

java -cp jars/mp.jar player.MusicPlayer ?

(Given you are currently in the directory /mp)
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Question classpath
 
Similar Threads
Mock question on classpath
Another Error in Master Exam...
Possibly misleading Master Exam question
Mock Exam Question Doubt, 36: 74 from K&B CD
Classpaths