简体   繁体   中英

Netbeans platform custom configuration file

I'm trying to create configuration file for database connection. Properties file would be best. This properties have to be changed after every application installation (customers database).

  • I want this config file in the root of application (netbeans platform project, and distro folder). I can't find way how to refer to application root folder.

  • I also find lack of documentation for FileUtil.getConfigFile/Root. I don't know where to find the configRoot (if it is even physical), or how to add ConfigFile offline (not in code, but just with copying config file).

  • Tolerable solution woud be to add database configuration to system properties, but i can't find where to specify additional system properties in netbeans configuration files.

您可以将属性文件放在其中一个模块的Release文件夹中,然后使用InstalledFileLocator API访问它: http//bits.netbeans.org/dev/javadoc/org-openide-modules/org/openide/modules/InstalledFileLocator html的

To access the the installation Directory of your NetBeans application you can use the following snippet

new File(System.getProperty ("netbeans.home")).getParentFile()

If you append '/etc' to the resultant file you will be in the the same folder that hosts the app.conf file.

Why don't you use app.conf ? It is located in ROOT/etc.

You could use system properties or, more elegant, an OptionProcessor

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM