• Post Reply Bookmark Topic Watch Topic
  • New Topic

Can you write to config files in jar files?  RSS feed

 
Tom McAmmond
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd love to distribute my app as a single jar file - however, like many programs mine requires a configuration file to keep program configuration data between app restarts.

Which is the best option for me?:

1) App dynamically creates config file upon first startup, user presented with dialog box to configure program.

2) App reads and writes to a pre-existing config file inside the app jar (can this even be done?)

3) App copies config file (complete with comments and examples) out of jar into same directory as jar upon first startup, user presented with dialog box to configure program

4) Other (please explain)

I appreciate any insight you might have. Thanks!
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what about the Preferences API ?? (note that there's a chapter about Preferences in the link.
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had a little look at the Preferences API a while back. It's Properties on steroids with transparent persistence.

You would still need to specify some defaults in your app and present the user with a config dialog on first use, i.e. effectively option 1, but without the file.

Jules
 
Tom McAmmond
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow.... I'd never heard of the Preferences API.... Many thanks for the link to that chapter! How could I have missed hearing about that?

Tom
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!