• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

importing packages

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know how to create a package, however I dont know how to make imports between packages. For instance if I have two packages named "first" and "second" how do I make imports from the first to the second or viceversa. Thanks in advance to everyone for your helpl!!!
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not GUI related. Moving to Beginning Java.
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What have you tried so far? This is a very basic question and with a couple of tries you should be able to figure it out on your own.
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well Jonathan, please take a look here. I think it will be helpful!
 
Jonathan Johansen
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think I did not explain myself very well. Say I have a package named cassi.DynamicTable under H:
so it would look something like this
H:---
cassi---
DynamicTable

Now suppose that I have another package named DynamicContainer under H: also
so it would look like this
H:---
cassi---
DynamicContainer


Both are under H:\\cassi . How can I import DynamicContainer into DynamicTable.

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If they are both in the same package, you don't need to import anything. Class DynamicContainer will be visible from DynamicTable without the need to do anything special (you don't even need an import statement).

*edit* Oh wait, you have packages called cassi.DynamicContainer and cassi.DynamicTable. I thought the last two were class names; it isn't very common to name packages with upper-case letters like you did.

In that case, add H:\ to your classpath, and in source files under cassi.DynamicTable, add an import statement like this at the top of your source files:

import cassi.DynamicContainer.*;

or, to import specific classes from that package,

import cassi.DynamicContainer.SomeClassName;
 
reply
    Bookmark Topic Watch Topic
  • New Topic