Re: can't import class in default package???
From: Dale King (kingd_at_tmicha.net)
Date: 12/16/03
- Next message: Ville Oikarinen: "Re: can't import class in default package???"
- Previous message: Peter Bradley: "Re: Netbeans: debugger"
- In reply to: Michael Amling: "Re: can't import class in default package???"
- Next in thread: Ville Oikarinen: "Re: can't import class in default package???"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 16 Dec 2003 16:03:42 -0500
"Michael Amling" <nospam@nospam.com> wrote in message
news:UM9Cb.11347$aw2.5793743@newssrv26.news.prodigy.com...
> Dale King wrote:
> > "Michael Amling" <nospam@nospam.com> wrote in message
> > news:4l%Bb.11120$aw2.5670827@newssrv26.news.prodigy.com...
> >
> >>Jon Skeet wrote:
> >>
> >>>Kay <kangkang@interchange.ubc.ca> wrote:
> >>>
> >>>
> >>>>I have a java fiile that resides at the default package under src
> >
> > folder. In
> >
> >>>>the same project, when I want to import that class, I just need to
type
> >>>>
> >>>>import ClassName
> >>>>
> >>>>right? However, eclipse cannot resolve it. But I can see the class in
> >
> > the
> >
> >>>>automatic code completion pop up list if I just type the first 1 or 2
> >
> > letter
> >
> >>>>of the ClassName.
> >>>>
> >>>>So what should I do to import such class?
> >>>
> >>>You should put the class into a package, instead. As of JDK1.4 the
> >>>above won't work with javac either.
> >>
> >> I noticed that. But I don't know who thought it would be a good idea.
> >
> > The creators of Java. Quoting from the JLS:
> >
> > "For small programs and casual development, a package can be unnamed or
have
> > a simple name, but if code is to be widely distributed, unique package
names
> > should be chosen. This can prevent the conflicts that would otherwise
occur
> > if two development groups happened to pick the same package name and
these
> > packages were later to be used in a single program."
> >
> > "Unnamed packages are provided by the Java platform principally for
> > convenience when developing small or temporary applications or when just
> > beginning development."
> >
> > The problem becomes complicated when you start thinking of multiple
> > hierarchies in the class path. For example, if I have a program in
multiple
> > jar files and a class uses a class in a class in an unnamed
package.Where
> > would it get it from? From the root of the jar file that class is in or
from
> > the root of the jar file of the class from which the program started?
> > Conceptually, you could have multiple unnamed packages.
>
> That's all been true since 1.0.3.
There is no such thing as 1.0.3. Java went from 1.0.2 to 1.1. And I fail to
see where I put any limits on when that was true. What has not been true is
that javac would not compile a file importing from the default package. That
did not happen until 1.4. There were other compilers, most notably Visual
Age for Java that did not support this as allowed by the JLS.
-- Dale King
- Next message: Ville Oikarinen: "Re: can't import class in default package???"
- Previous message: Peter Bradley: "Re: Netbeans: debugger"
- In reply to: Michael Amling: "Re: can't import class in default package???"
- Next in thread: Ville Oikarinen: "Re: can't import class in default package???"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|