• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

compiling interdependent classes and pachages

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have two packages, each package is dependent on the other. (Package A uses classes from package B. And package B uses classes from package A.) How can I compile each package, so they see the other dependent package? My compiler says it cannot resolve symbols since it cannot find the compiled packages.

I am using JCreator as my development environment. I don't know how to arrange the packages in directories to resolve these dependencies. Does JCreator require the .java files stored in a particular directory structure? Even classes within the same package can't see each other and I can't compile them.
 
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Nedyalka Gunderson:
I have two packages, each package is dependent on the other. (Package A uses classes from package B. And package B uses classes from package A.) How can I compile each package, so they see the other dependent package? My compiler says it cannot resolve symbols since it cannot find the compiled packages.

I am using JCreator as my development environment. I don't know how to arrange the packages in directories to resolve these dependencies. Does JCreator require the .java files stored in a particular directory structure? Even classes within the same package can't see each other and I can't compile them.



Until you completely understand how directories, packages and classpath are related, you should stay away from IDEs. They hide the real world, make complex problems too simple and simple problems too complex. Use a programmer's editor such as jEdit or TextPad and use Ant to build your project.

For those who will say that I hate IDE's because I've never used one, you are wrong. I've used NetBeans, Forte, Visual Cafe, Borland JBuilder, Oracle JCreator, Visual Studio.Net, VB5, VB6, VC++5, VC++6. These things are like power tools, its easier to cut square corners with a nice Makita compond mitre saw, but its also easier to lose a finger if you don't understand how it works..

What you need to do is build a directory structure from your classpath, eg. if classpath = C:\javadev\SCJD\classes, then you need a directory structure like:

C:\javadev\SCJD
C:\javadev\SCJD\classes\suncertify
C:\javadev\SCJD\classes\suncertify\db
C:\javadev\SCJD\classes\suncertify\gui
C:\javadev\SCJD\code\suncertify
C:\javadev\SCJD\code\suncertify\db
C:\javadev\SCJD\code\suncertify\gui

You put the code in the code subdirectories and ask your IDE to build the classes in the classes subdirectories. You then use the jar tool to build a jar file based on the classes.
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is having two packages depend on each other a good idea? Somehow it just doesn't sit well with me. Admitedly I don't have much experiance, but it just seems a "messy" way of doing things to me.

Any comments gratefully appreciated.

Michal
 
peter wooster
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Michal Charemza:
Is having two packages depend on each other a good idea? Somehow it just doesn't sit well with me. Admitedly I don't have much experiance, but it just seems a "messy" way of doing things to me.

Any comments gratefully appreciated.

Michal



The OP's problem with packages doesn't go this deep, they have problems with one package depending on another.

That said, its best if you can prevent or reduce such mutual dependencies. The Observer pattern is the most frequently used means of doing this. But one of your packages must still depend on another, eg. your GUI is dependent on your Business layer which is dependent on your network which is dependent on your database.

Frequently you will find that you have interfaces that make callbacks in the opposite direction possible, these can be replaced with the Observer pattern, as AWT does with the addxxxListener methods and anonymous inner classes. If there is never more or less than one listener for an event source, this pattern may add too much complexity.
 
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic