The nuts and bolts of module dependencies are as follows:
- Modules can load classes from modules they depend on. They have to declare a dependency on them.
- NetBeans doesn't care about things like the CLASS_PATH environment variable - it knows how to find modules in an install of NetBeans, and enforces dependencies between them
What this means is that if
- Module B tries to use a class from module A, but module B does not explicitly state that it depends on A...
- Module A tries to use a class from module B, and it does declare a dependency on Module A, but the package that class is in is not in the list of packages A says other modules can touch...
then a NoClassDefFoundException will be thrown at runtime (there is work happening to check this at build time too). A minor caveat to the second item is if Module B declares an implementation dependency on module A - then it will have access to the full set of classes (but it will be hard to upgrade B independent of A). Normally you don't need to do this.
Modules can also load classes from libraries - JAR files that are packaged with the module (see how to package libraries?). The following things are true about libraries:
- They are delivered to the user inside the NBM file if they are not part of a full application based on NetBeans
- When unpacked, the library will end up in $SOMECLUSTER/modules/ and any libraries will end up in $SOMECLUSTER/modules/ext
- The module will use the library by having an entry in its manifest Class-Path: ext/someLibrary.jar the same way any JAR would
If you are using module development support in 5.0, you will manage module dependencies on the properties pane for your module. For those who are interested, what this does in the background is to modify yourmodule/nbproject/project.xml. The data saved there is then used to generate the appropriate manifest entries for you.
If you need to do this manually, the following manifest entries are relevant:
is followed by a comma-delimited list of module code-names.
is followed by a comma delimited list of packages in your module (or in a library your module references by a Class-Path: entry).
If you are using NB 5.0's module building support, you don't need to manually edit either of these entries - the IDE will do it for you.
The details are available here.
Note that a module can declare very specific dependencies - i.e. that it must have version n.n or greater of some module. It is also necessary to depend on the release version if present (the /1 you see as part of the name of some modules).
Source: NetBeans FAQ