7 Replies Latest reply: Jun 29, 2007 8:56 AM by 807600 RSS

    importing same library into multiple files

    807600
      I'm working on a project with 2 files

      Both need to use objects contained in the library java.io.*

      Is there a way to use a single import statement to include this resource in both files?

      They're in the same package. How does importing work - if I import in both files will Java actually import twice or will it just use a pointer or what?

      thanks.
        • 1. Re: importing same library into multiple files
          807600
          The import doesn't actually import anything. It just tells the compiler what package the classes used in this file are in.
          • 2. Re: importing same library into multiple files
            807600
            Agree with Peete.

            Importing io package wont do much. It just says the required classes are in a particular package/place.
            No libraries are actually loaded. When the app runs, 'io' is loaded from JRE.
            • 3. Re: importing same library into multiple files
              807600
              so is there a way to consolidate the statements so that I don't have to re-import for every source file I create?
              • 4. Re: importing same library into multiple files
                807600
                so is there a way to consolidate the statements so
                that I don't have to re-import for every source file
                I create?
                Did you even read the replies you got? No, there isn't. The compiler needs to know what classes each individual class is dependent on, so you have to be explicit about it
                • 5. Re: importing same library into multiple files
                  807600
                  so is there a way to consolidate the statements so
                  that I don't have to re-import for every source
                  file
                  I create?
                  Did you even read the replies you got? No, there
                  isn't. The compiler needs to know what classes each
                  individual class is dependent on, so you have to be
                  explicit about it
                  show me where in the replies it says anything about where you have to do your imports and whether or not they can be consolidated - both replies are just answering the second part of my question about what actually occurs during an import -
                  • 6. Re: importing same library into multiple files
                    807600
                    so is there a way to consolidate the statements
                    so
                    that I don't have to re-import for every source
                    file
                    I create?
                    Did you even read the replies you got? No, there
                    isn't. The compiler needs to know what classes
                    each
                    individual class is dependent on, so you have to
                    be
                    explicit about it
                    show me where in the replies it says anything about
                    where you have to do your imports and whether or not
                    they can be consolidated - both replies are just
                    answering the second part of my question about what
                    actually occurs during an import -
                    In swatcat's reply, he said "It just says the required classes are in a particular package/place."

                    "Particular place" implies, to my mind, that it is an explicit declaration.

                    Was that really the best response to a straightforward answer? You're welcome, by the way
                    • 7. Re: importing same library into multiple files
                      807600
                      so is there a way to consolidate the
                      statements
                      so
                      that I don't have to re-import for every
                      source
                      file
                      I create?
                      Did you even read the replies you got? No, there
                      isn't. The compiler needs to know what classes
                      each
                      individual class is dependent on, so you have to
                      be
                      explicit about it
                      show me where in the replies it says anything
                      about
                      where you have to do your imports and whether or
                      not
                      they can be consolidated - both replies are just
                      answering the second part of my question about
                      what
                      actually occurs during an import -
                      In swatcat's reply, he said "It just says the
                      required classes are in a particular package/place."

                      "Particular place" implies, to my mind, that it is an
                      explicit declaration.

                      Was that really the best response to a
                      straightforward answer? You're welcome, by the way
                      I'm looking for explicit answers.

                      No thanks to you