This is the project blog of Multilingual NetBeans Community Docs Program- a community documentation project which has grown in leaps-and-bounds since it was launched in March, 2007. We have had high quality contributions and more enthusiastic community members.

We have stopped publishing weekly newsletters, however we started off publishing monthly one's instead. Scroll down for latest posts on this blog!

Last Updated: Oct 14, 2009

Thursday, October 9, 2008

Four Developer FAQs

Tom Wheeler was featured in our Weekly Newsletter #5, so lets take a quick look at what all he contributed during that time.

How can I suppress Unexpected Exception Dialog?
If your code generates an uncaught exception at runtime, NetBeans will display a dialog box which can show the details of that exception to the user. This is a welcome alternative to simply crashing the application, and provided you have written solid code, your user should never see this dialog anyway.


How can I register services into the Lookup using the System Filesystem?
In short, you probably do not want to. The typical way of registering services is via META-INF/services registration: DevFaqLookupDefault. That method is easier to use and offers compatibility with non-platform applications via the Java Extension Mechanism.


How can code in one module be notified when other modules are loaded or unloaded?
Let's begin by stating that you probably do not need to know when other modules are loaded or unloaded. The module system takes care of dependency management for you, so your module should never be loaded unless all of its stated dependencies are loaded too.


I got a ClassNotFoundException or NoClassDefFoundError. How can I fix it?

The most likely explanation is that you have a problem in your dependencies. In order for a class in one module to reference a class/interface defined in another module, the following must be true:
  1. The class/interface being referenced must be visible to the code using it, according to the normal Java visibility rules. This typically means that the class must be public, since package-private access across modules is impossible.
  2. The package containing the class/interface must be exported (marked as providing an API visible to other modules).
  3. The module containing the code which uses this class/interface must declare a dependency on the module which provides it.

Thanks, Tom!

No comments: