Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

.jar Files as Addon Modules

Status
Not open for further replies.

UMShadow

Programmer
Sep 29, 2002
6
US
Howdy all. I'm writing a little Java application that consists of a base app and as many addon modules as I feel like coding. To simplify distribution to users I would like to put the main app and each module into separate .jar files. Then I can tell users to put all modules in the "modules" subfolder.

However, I'm having trouble getting code in the main app to recognize code in the modules. I've tried various combinations of -classpath options and Class-Path entries in the manifest to no avail. The most common error is of course NoClassDefFound. I am able to get it working if I specify each .jar file explicitly, but since I won't know ahead of time what modules I might code, I can't really do that.

Suggestions? Thanks a lot.
 
I was under the impression that you had to specifiy each jar individually ...

The other option is to write your own ClassLoader implementation to load all your files.

--------------------------------------------------
Free Database Connection Pooling Software
 
I'm not sure if this will work. Try change the system property "java.library.path" to include the directory that your modules (jar files) are located.
 
@sedj: According to this page:


In the "More about the Class-Path Header" section near the bottom, it talks about using just a folder name. Perhaps the "resources" it talks about do not include jar files?

Writing my own ClassLoader seems a bit like overkill for this project, but maybe I'll check it out. :)

@byam: I'll check that out when I get home and let you know. Thanks.
 
I looked at my project that I'm working today. we actually achieved what you want by setting system property "java.ext.dirs". e.g.

-Djava.ext.dirs=..\lib

so if "java.library.path" doesn't work then, setting java.ext.dirs should does it.
 
Your second solution works well for what I'm trying to do. Not as smooth as I'd hoped, but it works, and that's what really matters. It all goes into a batch file anyway...

Thanks for the help!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top