java left logo
java middle logo
java right logo

Home arrow Other API Tips arrow NetBeans arrow How do module dependencies/classloading work
Main Menu
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog

Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews

Registered Users: 4118
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
How do module dependencies/classloading work E-mail
User Rating: / 1

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...
  • OR
  • 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.

If you are writing a module that will use some third party libraries, you probably want to read the section on wrapper libraries and also how to use them.

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

 Related Tips

< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.

Name (required)

E-Mail (required)

Your email will not be displayed on the site - only to our administrator

Comment Enable HTML code : Yes No

java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008
Java is a trademark of Sun Microsystems, Inc.