I am developing a plugin for NetBeans IDE 8.1 and I need to store persistent preferences to a file on disk, is there a standard location in NetBeans to store configuration files for plugins? And if there is such a place then what's the easiest way of defining it (as the NetBeans could be installed anywhere, especially depending on the OS)? Is there a special method or something which allows one to easily specify the location?
The Netbeans API defines the concept of the SystemFileSystem which is basically the config subfolder of your user directory. You're not supposed to directly place files there.
Netbeans provides both an annotation and file-based configuration deployment mechanism. For the file-based approach (what you're interested in), you're supposed to bundle the config file as an XML file, known as a layer file, and then define this file in your module's manifest. In doing this, the System Filesystem will create a subfolder in the config folder named for your module, containing whatever you define (NB defines a fairly robust and elaborate configuration management framework for modules).
An excerpt from the documentation:
- In your JAR, provide the layer file - e.g. com/foo/mymodule/resources/layer.xml
- In your module's manifest, include the following line somewhere in the top section:
Bottom Line: Bundle your config files inside your module jar. The API will handle the rest