This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Packages and Classes" Watch "Packages and Classes" New topic
Author

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:

package insy.java.hw7;

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

I am getting the following 2 errors saying:

Home.java:5 'class' or 'interface' expected
package.insy.java.hw7;
^

Home.java:7: 'class' or 'interface' expected
import insy.java.OurDate;
^

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

Joined: Jul 08, 2003
Posts: 24183
    
  34

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 insy.java package, you should not and need not import any other classes in that same package; they're available by default.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Packages and Classes
 
Similar Threads
How interface replace multiple inheritance(class)
help with a design approach
compile problem
jboss-ejb-Stateless?
implementing singleton pattern in an interface