Re: can't import class in default package???

From: Michael Amling (nospam_at_nospam.com)
Date: 12/12/03

  • Next message: Michael Amling: "Re: can't import class in default package???"
    Date: Fri, 12 Dec 2003 02:32:20 GMT
    
    

    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.

    --Mike Amling


  • Next message: Michael Amling: "Re: can't import class in default package???"

    Relevant Pages

    • Re: cant import class in default package???
      ... > Dale King wrote: ... >> a simple name, but if code is to be widely distributed, unique package ... >> The problem becomes complicated when you start thinking of multiple ... >> the root of the jar file of the class from which the program started? ...
      (comp.lang.java.softwaretools)
    • Re: cant import class in default package???
      ... "For small programs and casual development, a package can be unnamed or have ... The problem becomes complicated when you start thinking of multiple ... From the root of the jar file that class is in or from ... you could have multiple unnamed packages. ...
      (comp.lang.java.softwaretools)
    • Yum Problems, and Apt-Get Problems, Can Anyone help?
      ... .Package php-domxml needs libxsltbreakpoint.so.1, this is not available. ... am trying to install something. ... There are multiple versions of "autoconf213" in your system. ... you may remove that warning by setting the following ...
      (Fedora)
    • Re: Problems creatng executible jar files
      ... now I get an error message. ... make sure you have the jar file packaged correctly. ... When the JVM attempts to load a class with a package declaration, ... you asked about associating jar files on Windows. ...
      (comp.lang.java)
    • Re: Why is String immutable?
      ... classloader by replacing one of the classes in rt.jar with a modified ... rt.jar with a different JAR file where those packages are not sealed. ... Hostile code running within the JVM would not have the ability to ... Package signing is a different matter. ...
      (comp.lang.java.programmer)