The Artima Developer Community
Sponsored Link

Java Answers Forum
Import statement

3 replies on 1 page. Most recent reply: Jan 13, 2003 5:33 PM by Ugo Posada

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
Ken Reagan

Posts: 2
Nickname: ken
Registered: Jan, 2003

Import statement Posted: Jan 13, 2003 12:20 PM
Reply to this message Reply
Advertisement
I am just starting to learn Java. I have some code from a book. However, when I compile it I get a error message the it was expecting a '.' at the end of an import statement like:

import classname;

All the .java files that are referanced are in the same directory. Any ideas on what to try next would be appreciated.

Thanks


Matt Gerrans

Posts: 1153
Nickname: matt
Registered: Feb, 2002

Re: Import statement Posted: Jan 13, 2003 4:42 PM
Reply to this message Reply
Are you trying to import a class from the default package? If so, then you don't need to import it. You only need to import classes from packages, which would always involve the dots. For instance, to import all the classes and interfaces from a package called "silly," you'd have
import silly.*;
or to import just the class Thing, you'd have
import silly.Thing;
As you can see, imports always seem to involve dots.

Ken Reagan

Posts: 2
Nickname: ken
Registered: Jan, 2003

Re: Import statement Posted: Jan 13, 2003 5:03 PM
Reply to this message Reply
It is a user generated class. The .java code is in the same directory as the code I am trying to compile. Thanks

Ugo Posada

Posts: 37
Nickname: binaryx
Registered: Dec, 2002

Re: Import statement Posted: Jan 13, 2003 5:33 PM
Reply to this message Reply
If its in the same folder and it does not belong to a particular package you should not need to import the class at all.

Flat View: This topic has 3 replies on 1 page
Topic: ejb and context.close Previous Topic   Next Topic Topic: JNI help

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use