Note: These pages are being reviewed.
What class loaders are created by the module system?
This FAQ item should be a companion to the main classpath documentation. Please refer to the original document for additional details.
Class loaders in the NetBeans platform
There are basically three main class loader types used in the platform.
Most code is loaded by module class loaders.
In special cases the "system" class loader can be used,
when you need access to resources from unknown modules.
Resources directly on the classpath from the launch script (mainly
are loaded by the application loader.
(There are also bootstrap and extension loaders in the JRE,
and the platform has a special loader for a couple of JARs in
Most of the class loaders in the NetBeans platform are multi-parented class loaders.
This means that the class loader can have zero or more parents.
org.netbeans.ProxyClassLoader implements the search across multiple parents.
Module class loader
Every module loaded by the module system has its own class loader. This loader loads resources primarily from the module’s JAR. The application loader is an implicit parent of each module loader.
The module loader is able to load from additional JARs (besides delegating to various parents):
extensions - anything listed in the manifest attribute
Class-Pathof the module JAR
locale extensions - JARs placed in a subdirectory
localerelative to the original module JAR position, named by appending a locale suffix to the original name
patches - JARs placed in a subdirectory
patches/code-name-baserelative to the original JAR position (can override module classes)
The implementation class is
System class loader
The "system" loader loads no resources on its own,
but has as its parents all enabled module’s class loaders.
It is accessible via
or by using the fact that it is the context loader on all threads by default:
Application class loader
This class loader is set up by the launch script (or by
javaws if running in JNLP mode).
It can load classes from
lib/*.jar in specified clusters.
It is generally discouraged to use this loader for your own classes,
but it is sometimes needed e.g. for Look & Feel classes
(which must be loaded very early during the startup sequence).
Take a very simple module
Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.a
b depending on
Manifest-Version: 1.0 OpenIDE-Module: org.netbeans.modules.b OpenIDE-Module-Module-Dependencies: org.netbeans.modules.a Class-Path: ext/library-b-1.1.jar
org-netbeans-modules-a.jar will be loaded in
a’s module class loader.
Classes in both `org-netbeans-modules-b.jar and
will be loaded in
b’s module loader,
and can refer to classes in `org-netbeans-modules-a.jar.
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/DevFaqClassLoaders , that was last modified by NetBeans user Rmichalsky on 2009-12-02T13:43:15Z.
NOTE: This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.