I'm using gradle with the javafx-gradle plugin to produce a self-contained javafx application using the task "jfxDeploy".
I have the following directory structure:
|-- src
| |-- main
| |-- java
| | \-- Main.java
| |-- resources
| \-- database_config.properties
I'm loading the database configuration with the apache-commons-configuration and use its information to connect to to a database (information = port, ip - normal database stuff):
public static DBConnectionParameters getConfigDBConnectionParameters() {
try {
InetAddress ip = InetAddress.getByName(getProperty("configIP"));
String port = getProperty("configPort");
return new DBConnectionParameters(ip, port);
} catch (UnknownHostException e) {
e.printStackTrace();
}
return null;
}
After creating the self-contained application the build directory contains my program which is now startable using the .exe. The directory structure looks like that:
|-- AppName
| |-- app
| \-- externalJars.jar
| |-- runtime\...
| \-- AppName.exe
| \-- AppName.ico
Starting the program, reading the database configuration and connecting to the database works fine, but: I need to be able to change the database_config.properties every now and then. But since I now got my self-contained app, the file is not accessible anymore. So, i need a editable file for configuring my parameters - while at the same time using a self-contained application. To prevent misunderstanding: the configuration file does not need read protection. What i need is (and it's perfectly fine) the file just laying in the application folder (or a subdirectory).
I like to keep my applications dynamic - and a little file for fast configuration is perfect for achieving that. How to do it?