Solved

working with packages

Posted on 1998-04-27
2
136 Views
Last Modified: 2010-04-16
In my Java-application I want to use packages because I have about 78 classes.
I want to devide them into 1 main package and 3 subpackages :
main : "ipstool" (which contains only the class with the main-method)
sub : "data", "exceptions" and "interface".
In every class of a certain package (all in one directory with the same name as the package..) I put
     package data;
in front of the import-statements.
Also I put there the other packages of my application, f.e. :
    import ipstool.exceptions.*;
    import java.awt.*;
I'm compiling from the directory that contains the "ipstool"-directory.

This doesn't compile however...
What am I doing wrong? Should I put something in the classpath or is it not necessary to import them as ipstool.exceptions.* but as exceptions.* or maybe something else ?
0
Comment
Question by:Jeppe041198
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:Jeppe041198
ID: 1219970
Edited text of question
0
 
LVL 16

Accepted Solution

by:
imladris earned 50 total points
ID: 1219971
From your description of the hierarchy, the "main" class would have to be in a subdirectory named ipstool, and the others in subdirectories below that. Or, to put it another way, if your classpath in effect is pointing to directory ipstool, you need to reorganize to have it point to one directory higher (ipstools parent), i.e. compile from the parent directory.

On the other hand, I have found that some Java environments (e.g. J++) are unhappy with Java programs that don't have a default package. The solution I would recommend is to make your "main" class be the default package, and the other three be package data, exceptions etc., in directories below.

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question