Note: These pages are being reviewed.
When should I use a library wrapper module and when should I just package the library into my module?
The New Module Wizard offers easy support for creating a wrapper module: File > New Project > NetBeans Modules > Library Wrapper Module and since NetBeans 6.8 it is similarly easy to either edit Library Wrapper Module after it has been created or package library directly to your module via Project Properties > Libraries > Wrapped JARs.
Before NB 6.8 it was more convenient to create Library Wrapper module due to existence of the wizard, but not Project Properties UI. This biased the answer to this question, but generally there’s no harm in using a library wrapper module.
Note that a library wrapper module can wrap more than one external JAR - you do not need to create one for each library. But it is a good idea to create a separate wrapper for each JAR if they come from different projects and might conceivably be used independently.
The general algorithm for making an optimal decision about when to use a wrapper module is this:
If the library is from some third-party source, and your module is just using it, then
If it is something very esoteric and your module will be the only module in an installation of NetBeans (or your NetBeans-based app) ever using it
You are writing only one module that will use the library, or you want to declare the packages contained in your library in the public packages of your module
If you will never want deliver an update of that library by itself, without delivering an update of your module
Then you probably just want to package the library directly into your module, as in DevFaqModuleDependencies
If you wrote the library you want to use
You might just want to add the appropriate
OpenIDE-Module-*entries directly to its manifest and make it a module that way. Remember to list the packages your module will need to export.
Else, you probably want to read DevFaqWrapperModules
There is a very slight performance penalty to using a wrapper module - it’s one more JAR to open and read from, and one extra layer of indirection for the classloader. That is not a reason to avoid using a wrapper module if that’s what you need - it really is slight. In a very large application such as the NetBeans IDE, such considerations are more important because there are more JARs, more classloaders, and hence more overhead already.
If you are developing the library yourself, but decide you want to keep the library project separate from any NB module project, you can do so. See Using a wrapper module for an existing project for information and various methods to hook them up for development.
Applies to: NetBeans 6.8 and above
Apache Migration Information
The content in this page was kindly donated by Oracle Corp. to the Apache Software Foundation.
This page was exported from http://wiki.netbeans.org/DevFaqWhenUseWrapperModule , that was last modified by NetBeans user Rmichalsky on 2009-12-02T15:00:34Z.
NOTE: This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.