• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

classpath for the .java

 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, this question is in K&B quiz,
There are three versions of MyClass.java at
Version 1: /foo/bar
Version 2: /foo/bar/baz
Version 3: /foo/bar/baz/bing

and the system classpath /foo/bar/baz

What command line option will use the version 2?
1. javac -cp /foo/bar:/foo/bar:. MyClass.java
2. javac -cp /foo/bar/baz:/foo/bar MyClass.java
3. javac -cp /foo/bar/baz/bing:/foo/bar:. MyClass.java
4. javac -cp /foo/bar/baz/bing:/foo/bar/baz MyClass.java
5. Not predictable

Answer is given as option 2

But i think the classpath has nothing to do with the .java files for compilation.
So the answer should be Option 5 Not Predictable as our current directory may not contain the MyClass.java
Can somebody expalin
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with you. -cp should come into picture when the .java being compiled uses some classes. In this case, that doesn't seem to be the case. So, -cp is irrelevant.
 
S Thiyanesh
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks.
 
Ranch Hand
Posts: 144
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You are right. The "javac..." should be replaced by "java..." .

Since it's unpredictable which directory we are in (i.e, we don't know if it contain's version 2), the only answer is 2.

The classpath must be specified explicitly although the CLASSPATH was mentioned to be explicitly set to point to version 2.

So we need the absolute path because no other options in the choices shows we making package directory of version 2 the current directory.
[ June 12, 2006: Message edited by: Firas Zureikat ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic