• Post Reply Bookmark Topic Watch Topic
  • New Topic

importing packages  RSS feed

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • 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: 21136
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not GUI related. Moving to Beginning Java.
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • 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: 2273
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • 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;
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!