NetBeans Platform: Setting dependencies/accessing methods from other modules
-
13-12-2019 - |
Question
I have a question regarding the use of NetBeans Platform and setting dependencies or simply referencing classes from another module.
What I have:
NetBeans Platform Application with a main module called Viewer
com.demo.viewer
-MainScreenTopComponent.java
And I have a module named MenuToolbar
com.demo.toolbar
-menutoolbar.java
-action1.java
menutoolbar.java has a method that I would like to access from the MainScreenTopComponent.
I have tried right clicking the Viewer module, going to properties >Libraries and adding dependency on the MenuToolbar module, however I still cannot even import the package.
Any help is appreciated =(
Thank You!
Edit: Solved myself. Instead of adding dependency in Viewer, I added a Warpped Jar which I found in my platform's Build/Clusters/Modules folder!
Solution
No need to use a wrapped JAR.
You need to export the classes from within the module MenuToolbar:
- right click on your module
- select properties
- click on "API Versioning"
- check the package
com.demo.toolbar
in the list of packages labelled "Public Packages"
This assumes your MenuToolbar module is already part of your NetBeans platform application