*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes packages imported correctly but the source files are not getting compiled well from K & B chapter 10 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "packages imported correctly but the source files are not getting compiled well from K & B chapter 10" Watch "packages imported correctly but the source files are not getting compiled well from K & B chapter 10" New topic
Author

packages imported correctly but the source files are not getting compiled well from K & B chapter 10

Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 438

I was trying a little experiment with the source files in different packages
but I am getting following errors
this is my directory structure and the programs also are given below

Directory structure is


following are the source files


and when I compile the program using commands then I get following error messages


please help me


SCJP 6 [86%] June 30th, 2010
OCPWCD [84%] March 26th, 2013
If you find any post useful, click the "plus one" sign on the right
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1634
    
  23

Hi Prasad,

javac JarDemo/first/B.java
JarDemo\first\B.java:7: cannot find symbol

B.java uses something from class C.java, so you have to give the path to the compiler when compiling class B

you have to use the command javac -cp

have a look at my notes (SCJP Faq) chapter 10

Regards,
Frits
Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 438

I tried like you said but it is not working
I know I have made mistake but can't figure out where
and I could not find any satisfactory answer in the link you provided
I tried following commands now
but not working
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

For static members, you should use static imports, like,



|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1634
    
  23

Hi Prasad,

Change the following method call (in public class A)
into

Change the following method calls (in public class B)
into

then compile with the package dir as a subdir (i.e. from your root):
javac JarDemo\first\subFirst\C.Java JarDemo\first\B.java JarDemo\A.java

Regards,
Frits

Prasad Kharkar
Ranch Hand

Joined: Mar 07, 2010
Posts: 438

Thanks Frits
that helped
resolved
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: packages imported correctly but the source files are not getting compiled well from K & B chapter 10
 
Similar Threads
using the javac -cp command
Access modifiers
package problems...
Package: resolving the class
Help with Package understanding