895265 wrote:Why do you need to store them in a properties file if they're already in the database?
Sorry, but could you at least point me to the right direction here pls? When I run the program, I read some information from the database and I need to store them to my properties file. So then how could I do this
jverd wrote:Or for an incredibly simple solution, create the file in the user home folder (System.getProperty("user.home")) which is guaranteed to exist and write-enabled and is of course bound to a single user only in stead of all users on the system.
2) From the DB or from a System property (specified with -Dprop=value at startup), obtain a location on the file system where you can write the properties file.
gimbal2 wrote:If you did have that twinge of guilt, you could create a folder in the user's home directory where your application could dump all its rubbish, I mean store its config file.
You'd reason that it is bad practice to pollute the user home dir with config files, but so many apps, Java or otherwise, already do so anyway :/
895265 wrote:Databases can do that as well. So can java.util.prefs.
Mostly I need the properties file to save some decisions my user will make. Like for instance, when he tries to open a scan, he can choose a folder with his scans and he will see this folder every time he opens file chooser. And the program needs to remember what the user has chosen even after the user exits. And I can only do that with properties file as far as I know.
What about the option of reading a .properties file from .jar. For instance, i have a .jar file which contains my classes. The .jar file is in a directory called InstallationFolder, and the .properties file is there also. So the structure would be sth like this:You can read from the jar, yes, but you cannot write to it. It's not a file system. I thought this was your problem in the first place--that you knew how to read from a jar but were trying to write to it as well.
In myApp I have a mainClass, which contains a method writePropFile and readPropFile. Could I access the properties file from these two methods from mainClass? How could I include the .properties file classpath to mainfest file? Because now netbeans creates manifest file on it's own and classpath only includes libraries.You can read it if it's on your classpath, using getResource or whatever, but you can't write to a classpath resource.
Could sth like that work? How could I access the properties file then?