By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,468 Members | 1,859 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,468 IT Pros & Developers. It's quick & easy.

Referring to packages

P: n/a
Can anyone explain how i can refer to another package that is at the
same 'level' in the directory structure as the one doing the
referring. i.e given the package structure: -

basedir
| |
package1 package2

how can i gain access to a class within package2 from within a source
file from package1 -- i only seem to b able to access classes within
packages/directories that are BELOW the package doing the referring.
In the context im thinking of i have a GUI package and a number of
DATA packages - i want the GUI classes to be able to access DATA
classes but also want DATA packages to refer to one another -- its not
essential that the classes are organized this way but seems like a
'common-sense' way of dividing up my classes to make them more
manageable.

cheers

P@
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Patrick Robinson" <ip****@central.sussex.ac.uk> wrote in message
news:c7*************************@posting.google.co m...
Can anyone explain how i can refer to another package that is at the
same 'level' in the directory structure as the one doing the
referring. i.e given the package structure: -

basedir
| |
package1 package2

how can i gain access to a class within package2 from within a source
file from package1 -- i only seem to b able to access classes within
packages/directories that are BELOW the package doing the referring.
In the context im thinking of i have a GUI package and a number of
DATA packages - i want the GUI classes to be able to access DATA
classes but also want DATA packages to refer to one another -- its not
essential that the classes are organized this way but seems like a
'common-sense' way of dividing up my classes to make them more
manageable.

cheers

Given:
--Project Folder
----myapp
------gui
Jul 17 '05 #2

P: n/a
"Patrick Robinson" <ip****@central.sussex.ac.uk> wrote in message
news:c7*************************@posting.google.co m...
Can anyone explain how i can refer to another package that is at the
same 'level' in the directory structure as the one doing the
referring. i.e given the package structure: -

basedir
| |
package1 package2

how can i gain access to a class within package2 from within a source
file from package1 -- i only seem to b able to access classes within
packages/directories that are BELOW the package doing the referring.
In the context im thinking of i have a GUI package and a number of
DATA packages - i want the GUI classes to be able to access DATA
classes but also want DATA packages to refer to one another -- its not
essential that the classes are organized this way but seems like a
'common-sense' way of dividing up my classes to make them more
manageable.

cheers

Oops. Accidental send.

Given:
--Project Folder
----myapp
------gui
------data1
------data2

You'll run the program from "Project Folder" via a command like "java
myapp.gui.MyMainClass". To access classes in the other packages:
import myapp.gui.*;
import myapp.data1.*;
import myapp.data2.*;
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.