Bram
Bram

Reputation: 121

What is the right location to store persistent objects?

I am developing a medium Java desktop application, without using a database. I am using xml, serializable objects, etc. to store the user/application data, but what is the right location to save these files to (system-independent)?

Upvotes: 2

Views: 289

Answers (3)

Stefan Kendall
Stefan Kendall

Reputation: 67812

Why aren't you using a database? Use file-system database (like hsqldb) and an object relational mapping layer. You probably won't even need to write a mapping file of any kind, or arbitrarily make your classes serializable.

Store data in %APPDATA%/appName on windows, and probably ~/.appName on linux. User/Library/Application/appName could work on macs.

Upvotes: 2

TofuBeer
TofuBeer

Reputation: 61526

If you really don't want to store them in a data base take a look at the Preferences API it is platform neutral.

Upvotes: 2

cjstehno
cjstehno

Reputation: 13984

Most, if not all, OSes have a concept of a home directory where you end up having a lot of hidden configuration directories of one form or another. You could create a hidden directory under the users home directory and store your configuration/data files there.

Upvotes: 1

Related Questions