In the API Versioning panel in the Project Properties dialog box for NetBeans module projects, there is a "Public Packages" checkbox. You can specify that a package is public, which is not the case by default. What effect does this have? Follow the steps below to find out.
- Create a module suite project. Set the project name as "MyNewSuite". Click Finish.
- Right-click the suite's Modules node. Choose Add New. Type "ModuleA" as the project name. Click Next and Finish.
- Repeat the step above, but name the module "ModuleB".
- Create an empty class in the org.yourorghere.modulea package created for you in ModuleA. Use the default name "NewClass".
- Right-click ModuleA and choose Properties. In the Project Properties dialog box, select "API Versioning". In the "Public Packages" list, select the org.yourorghere.modulea checkbox. Now other modules can use this package. Make sure there's a check mark in the checkbox and then click OK to close the Project Properties dialog box.
- Right-click ModuleB and choose Properties. Click Libraries and type "modulea" in the Filter. The "Module" list shows your "ModuleA". Notice in the description that org.yourorghere.modulea.NewClass is listed. This shows you that you can use it in your module, because it belongs to ModuleA's public package. Click OK. Then click OK again to exit the Project Properties dialog box.
- In ModuleB, create a new class called "NewClass1", in the main package, which was created for you, called "org.yourorghere.moduleb".
- In ModuleB's constructor type this:
NewClass a = new NewClass();
- Place your cursor on the line above. A lightbulb appears. Click on the lightbulb and let the IDE add the import statement for org.yourorghere.modulea.NewClass.
Hurray, you're now using a class belonging to ModuleA in ModuleB. This is how it works, so don't forget to check the "Public Packages" checkbox, if needed, otherwise you won't be able to access classes from one module in another.