wood burning stoves
The moose likes Beginning Java and the fly likes Creating a package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Creating a package" Watch "Creating a package" New topic

Creating a package

Deon Smith

Joined: Mar 08, 2002
Posts: 7
I'm trying to create some packages. But I'm getting a compile error when I try to compile the second class in the other package.
package pack1;
public class PackOne {
protected int a = 9;
package pack2;
public class PackTwo extends PackOne {
//do something
I'm getting an error stating that PackOne cannot be resolved.
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Deon,
You need to import the package to make its contents visible. So just add:

after the package statment and before the class definition and PackTwo should compile fine.
Hope this helps,
Michael Morris
[ August 11, 2002: Message edited by: Michael Morris ]

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
I agree. Here's the link: http://aspose.com/file-tools
subject: Creating a package
jQuery in Action, 3rd edition