Re: How can I write values in a properties-File which is located in a JAR without copying the whole JAR?
I have a question concerning properties-files in Java.
Writing in a properties-file and reading out of the file is working as
long as I don't put my files in a JAR.
The best approach to user here, is to treat the
properties file in the jar as simply an 'initial'
Check in "user.home"/our/backward/domain/
for the properties file. If it is not there, read it
from out of the jar, and write it to there.
Proceed loading the property file from the
sub-directory of user.home.
Using this scheme, you can also offer a
'revert properties to defaults' option in the
GUI, by simply retoring them from unchanged
version in the Jar. ;-)
But no, attempts to *edit* or *update* the actual
resource in the Jar file will probably fail, or end
in a very fragile application.
The adventureous part of the programm is that I'm trying to make an
application which should be able to remember user-settings (write
values in properties-file) and load them (read out values of
properties-file) when started next time.
Here is an example of storing user preferences.
It makes use of the web start API's PersistenceService
to do the same basic thing I described above, but for a
sandboxed app. launched using web start (and with no
specific '.properties' file to begin with).
...(The user just has to unzip a ZIP-archive, which includes
a folder with the necessary libraries and a JAR-file with my classes.)
'Tut-tut' - use web start for the launch - much easier
for the end-user.
Message posted via JavaKB.com