aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes SCJP chapter 10 : Development Classpath problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "SCJP chapter 10 : Development Classpath problem" Watch "SCJP chapter 10 : Development Classpath problem" New topic
Author

SCJP chapter 10 : Development Classpath problem

Swapnil Suryakant Prabhavalkar
Greenhorn

Joined: Feb 25, 2012
Posts: 23

Hi all,

One more question from K&B that I am not able to understand.

Question is :

Given the default classpath:

/foo

And this directory structure:



And these two files:





which allows B.java to compile?

According to me, below answer is also valid:

Set the current directory to xcom then invoke
javac - classpath . B.java


Could you please explain me why this will not work? According to me , it should work correctly.

Thanks in advance.


Oracle Certified Professional, Java SE 6 Programmer (81%), Oracle Certified Expert, Java EE 6 Web Component Developer (87%)
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9313
    
  17

Since the current directory is xcom, so when you compile B.java compiler will look for class xcom.A in xcom directory i.e. the compiler will look for foo/test/xcom/xcom/A.java


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Swapnil Suryakant Prabhavalkar
Greenhorn

Joined: Feb 25, 2012
Posts: 23

Hi Ankit,

Thanks.

Sorry but I didn't understand! If A.java and B.java are in same package then why compiler pre-pends xcom again to A.java?
Matheus Souza
Ranch Hand

Joined: Mar 06, 2012
Posts: 38

Swapnil Suryakant Prabhavalkar wrote:Hi Ankit,

Thanks.

Sorry but I didn't understand! If A.java and B.java are in same package then why compiler pre-pends xcom again to A.java?


If you want to compile the B.java file you need to be in its root folder, so if you're in xcom folder you'll need to do this
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SCJP chapter 10 : Development Classpath problem