Can class definitions for a single package be spread across several JARs?
Can I put some class definitions for some extensions to a package in a different JAR file, without making it a different package?
My reason for wanting to do this is that I'm trying to write some extensions to a package written by someone else. He and I both frequently issue new versions, and it would be much easier when he produces a new version if all I or other users had to do was copy his new JAR file into their application directory. If I'm only allowed to use a single JAR file, then I have to rebuild the whole application every time he produces an update.
Is this a good reason for having a package in multiple JAR files?
Is there a better way of achieving what I'm trying to achieve?
Thanks - Rowan
Re: Can class definitions for a single package be spread across several JARs?
What happened when you tried?
And why don't you use some kind of version control system?
Re: Can class definitions for a single package be spread across several JARs?
Quote:
Originally Posted by
KevinWorkman
What happened when you tried?
Well, I've been struggling to get everything in the right directories and everything named correctly, but I finally think I've found a way of making it work, and the answer seems to be that it works OK. It does successfully find my derived classes in my new JAR file, and treat them as part of the same package that's in the original JAR file.
Quote:
Originally Posted by
KevinWorkman
And why don't you use some kind of version control system?
I do, for the code that I write. And the guy who wrote the original application uses one too, that I have read only access to. But how does this help? I don't particularly want to ask him for full access to his CVS system. He probably would not give it to me, and in any case I'm not sure I want to expose my beginner's efforts to him at this stage...
Anyway, it seems to be working, so I seem to have answered my own question. If you know of a better or more elegant way of achieving this (it's effectively extending the functionality of a package without the need to modify or rebuild the original at all, and potentially without even the need to have the source code of the original) please let me know.
Thanks - Rowan
Re: Can class definitions for a single package be spread across several JARs?
Some issues you might want to consider- what if both Jars contain the same class name in the same package? What if an expected class is removed from one of the Jars?
I'm not sure your goal of extending a package like that is best (what's so wrong with using your own package?), but only you know your specific context, so it's up to you.
Re: Can class definitions for a single package be spread across several JARs?
Quote:
Originally Posted by
KevinWorkman
What if both Jars contain the same class name in the same package? What if an expected class is removed from one of the Jars?
Well, I will be careful not to duplicate a classname that's used in the "original" package. In any case I would immediately find this out when I tested the solution. If the original developer by coincidence adds a classname to his application which duplicates one I've already created, my version of the app will stop working, and I'll just have to fix it if this happens. Not ideal, I know, but a fairly remote chance in this particular case, so one I will live with.
Quote:
Originally Posted by
KevinWorkman
what's so wrong with using your own package?
Well, the package name is hard coded into his part of the application, so if I use a different one (that's what I tried first) my code never gets called. That's what led me to ask this question in the first place.
Anyway, thanks for your interest and help. I've learnt something, and my solution is working so progress has been made!
Rowan