Note: These pages are being reviewed.
How do module dependencies and class loading work?
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 does not care about things like the
CLASSPATHenvironment variable - it knows how to find modules in an installation 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, or…
Module B tries to use a class from module A, 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…
NoClassDefFoundException will be thrown at runtime.
(If you even get that far - the module build harness will refuse to even compile module B in such cases.)
An exception to the second item is that if Module B declares an implementation dependency on module A, then it will have access to the full set of classes. Normally you should not need to do this, and anyway it will then be hard to upgrade B independently of A.
Modules can also load classes from libraries - JAR files that are packaged with the module (see DevFaqHowPackageLibraries). Some points to remember 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 module will end up in
$SOMECLUSTER/modules/and any libraries will end up in
The module will use the library by having an entry in its manifest
Class-Path: ext/someLibrary.jarthe same way any JAR would.
If you are using the IDE’s module development support,
you will manage module dependencies in the properties dialog for your module
(or the Libraries node in the Projects tab).
This just modifies
The data saved there is then used to generate the appropriate manifest entries for you.
For more details, see the reference documentation about classloading in NetBeans.
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/DevFaqModuleDependencies , that was last modified by NetBeans user Rmichalsky on 2009-12-02T13:40:56Z.
NOTE: This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.