File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Packages and Classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Packages and Classes" Watch "Packages and Classes" New topic

Packages and Classes

Holly Leery
Ranch Hand

Joined: Sep 08, 2004
Posts: 97
I have a question. I have three classes that I want to put into one pacakge and I was wondering if there is anything in particular I should do. I want them all in:


I have that at the beginning of all three classes (House, Home, OurDate).

I am getting the following 2 errors saying: 'class' or 'interface' expected;
^ 'class' or 'interface' expected

Thank you for any comments, I am sure it is something stupid Thanks a lot!!
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195

Well, that period in between the word "package" and the "insy" doesn't belong there. The second error may just be the result of the first. Note that the "package" line has to be the first non-comment line in the file, and the "import" lines have to come after any package line, but before anything else. For example

is a valid file with one of each.

Note, by the way, that if your class is in the package, you should not and need not import any other classes in that same package; they're available by default.

[Jess in Action][AskingGoodQuestions]
jQuery in Action, 3rd edition
subject: Packages and Classes
It's not a secret anymore!