aspose file tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes how javac search file? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Professional Certification » Programmer Certification (SCJP/OCPJP)
Reply Bookmark "how javac search file?" Watch "how javac search file?" New topic
Author

how javac search file?

appu sharma
Ranch Hand

Joined: Sep 20, 2009
Posts: 102

/top
|-----wrk
*****|------pkg
*********|----A.java
*********|----B.java
star here only repesent space

//Filename A.java
package pkg;
class A{ B b ;}

//Filename B.java
package pkg;
class B{........}
when i am trying to compile it
Current directroy : /top/wrk
command: javac -cp . pkg/A.java
its fine
but when i am trying to compile by
Current directroy : /top/wrk
command: javac -cp .:pkg pkg/A.java
i got an error like this
C:\Documents and Settings\vinit\Desktop\wrk>javac -cp .:pkg pkg/A.java
pkg\A.java:4: cannot find symbol
symbol : class B
location: class pkg.A
B b;
^
1 error
why???


It doesn't matter if you win by an inch or a mile; winning's winning.
Prithvi Sehgal
Ranch Hand

Joined: Oct 13, 2009
Posts: 767
Please use code tags so that it becomes more readable and can be answered precisely.

Best Regards,


Prithvi/Beenish,
My Blog, Follow me on Twitter,Scjp Tips, When you score low in mocks, Generics,Scjp Notes, JavaStudyGroup
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 14606


The classpath is only for the top level directories. There is no need to specify the pkg directory. Try removing it. Also, delete all you .class files -- just in case there is one that is interferring with the compilation.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
appu sharma
Ranch Hand

Joined: Sep 20, 2009
Posts: 102

Prithvi Sehgal wrote:Please use code tags so that it becomes more readable and can be answered precisely.

Best Regards,

where should i use code tag, it is not code???
The directory sturcture is above

the whole question is this and its from K&M page 127.
//Filename A.java
package pkg;
class A{ B b ;}

//Filename B.java
package pkg;
class B{........}

Selsct two answers:
a) Current directroy : /top/wrk
command: javac -cp .:pkg A.java

b) Current directroy : /top/wrk
command: javac -cp . pkg/A.java

c) Current directroy : /top/wrk
command: javac -cp pkg A.java

d) Current directroy : /top/wrk
command: javac -cp .:pkg pkg/A.java

e) Current directroy : /top/wrk/pkg
command: javac A.java

f) Current directroy : /top/wrk/pkg
command: javac -cp . A.java
appu sharma
Ranch Hand

Joined: Sep 20, 2009
Posts: 102

Henry Wong wrote:


Henry Wong

Congt. for ten thousand message
bhanu chowdary
Ranch Hand

Joined: Mar 09, 2010
Posts: 256
vinit,

i guess you are working on windows system. If my guess is correct, please use ; instead of : when compiling.

Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 14606

vinit sharma wrote:
Selsct two answers:




Didn't realize that this was a test question... please QuoteYourSources.

Henry
appu sharma
Ranch Hand

Joined: Sep 20, 2009
Posts: 102

bhanu chowdary wrote:vinit,

i guess you are working on windows system. If my guess is correct, please use ; instead of : when compiling.


yes thanks i forget that : is used in unix not window
vinit
appu sharma
Ranch Hand

Joined: Sep 20, 2009
Posts: 102

Henry Wong wrote:
vinit sharma wrote:
Selsct two answers:




Didn't realize that this was a test question... please QuoteYourSources.

Henry

Khalid A. Mughal 3rd Edition page 127.....
thanks for your time but its clear now...
vinit
 
IntelliJ Java IDE
 
subject: how javac search file?
 
Threads others viewed
package problems...
question and sample problem about classpath
K&B chapter 10 Q5 classpath question
using the javac -cp command
using classpath with javac Problem
developer file tools

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture