File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Package Searching Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Package Searching" Watch "Package Searching" New topic
Author

Package Searching

Denise Advincula
Ranch Hand

Joined: Jan 01, 2007
Posts: 160
Hello, I hope you can help me. I can't figure out how to compile this program successfully using javac.

I have two packages: p1 contains A.java, p2 contains B.java. They're in this folder: "packages".


This is how it's structured:

packages
- p1 - A.java
- p2 - B.java

B.java needs to access A.java so it has an import p1.* statement. I keep on getting this error when I try to compile B.java:



I know something's wrong with my invocation but can anyone please correct me? I tried a lot of stuffs already but nothing seems to be working. Thank you in advance!
[ September 08, 2008: Message edited by: Denise Saulon ]

SCJP/OCPJP 6 | SCWCD/OCPJWCD 5 | OCMJEA in progress...
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9280
    
  17

compile B.java as

javac -d classes -cp classes p2/B.java

as p1/A.class is in classes folder...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Denise Advincula
Ranch Hand

Joined: Jan 01, 2007
Posts: 160
It worked!! Finally I get the idea now. Thank you for your support!
 
wood burning stoves
 
subject: Package Searching
 
Similar Threads
Question from JQPlus
protected variable?
jplus question
Help on Packages!!
why isn't it compiling?