By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,469 Members | 1,885 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,469 IT Pros & Developers. It's quick & easy.

import HelloImport; Package required?

P: n/a
What grammer requires that an import must be for a package?
The following gets an error:

dir structure:
--------
src\
HelloImport.java
examples\
HelloWorld.java

src:
--------
12: package examples;
13: import HelloImport;
14: public class HelloWorld {
....

error:
--------
examples/HelloWorld.java [13:1] '.' expected
import HelloImport;
^
1 error
Errors compiling HelloWorld.java.
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
news.verizon.net wrote:
What grammer requires that an import must be for a package?
The following gets an error:

dir structure:
--------
src\
HelloImport.java
examples\
HelloWorld.java

src:
--------
12: package examples;
13: import HelloImport;
14: public class HelloWorld {
...

error:
--------
examples/HelloWorld.java [13:1] '.' expected
import HelloImport;
^
1 error
Errors compiling HelloWorld.java.


Given your directory structure, HelloImport.java is in the 'default'
package, which basically has no package. In that case, you don't need to
import it.

The cause of the error is a package name has more than one component to
it - 'HelloImport' is not a valid package name.

Joe
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.