I am working on a Java SE project that has both a library part (a few packages of public
classes) intended to be used by programs written by othe开发者_JAVA技巧rs and an applications part (classes with main()
methods) that use that library. So the installation evironment must handle the possibility of there being multiple applications programs simultaneously present and using different versions of the library. Any ideas on how to handle this? How do people avoid JAR hell?
A future version of Java will incorporate the Jigsaw functionality. Enterprise applications can make use of the OSGi component functionality. But what about non Enterprise applications now? Is there anything simpler than OSGi that gets the job done?
Edit, after some preliminary answers: I can handle the build-time dependency problem reasonably well using our version control and build process. Its help with the run-time dependency problem I'm really interested in.
Sure: Maven
Sorry, misread the question.
You can use OSGi (Equinox or Felix) in any application, it doesn't have to be an enterprise (server based) application.
That said, you can easily control the visibility of your classes yourself by creating URLClassLoader
s as needed. That's how the OSGi implementations do it.
Apache Ivy is a light-weight solution. It does only dependency management and doesn't try to change your build system to match.
Use Maven.
Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.
If all you want is dependency resolution, then Apache Ivy fits the bill. It performs similarly to Maven's dependency resolution, but lacks Maven's complexity since it has much fewer features.
I don't know that I've ever heard the term "runtime dependency" used in a Java context. Runtime dependencies, as I'm familiar with, are usually handled through application context. The Spring Framework is one such way to manage application context.
精彩评论