I am considering switching to web start for deploying my application so that I can take advantage of it’s built-in auto-updating features, but I am trying to locate information on the preferred method of storing stuff like the player’s preferences, or perhaps chat logs, etc. Should I just ask for permission to create a folder on their drive and store it there?
Have you tried the stuff in the java.util.prefs package yet? From the java.util. prefs package description:
[quote]This package allows applications to store and retrieve user and system preference and configuration data. This data is stored persistently in an implementation-dependent backing store. There are two separate trees of preference nodes, one for user preferences and one for system preferences.
[/quote]
I don’t know if it will work, I haven’t used JWS yet.
I looked at it, and I think that most or all of the classes are abstract, and are meant to be frontends for database-driven storage that you or (if there are libraries out there for this) someone else implement. The same question about where to stick the files would still apply. Is there a ‘standard’ or canonical place that JWS coders put this kind of thing? I feel like just creating a directory in the root of my user’s hard drive space is a bit unfriendly and presumptious ;D
The classes are astract because they encourage custom implementations but that doesn’t matter, each JVM comes with a default implementation and you can access it with the static method at: java.util.prefs.Preferences.userRoot() . Now the question is how does this behave in the context of JWS?
Missed that on my glance-through, but the docs still raise more questions than they answer. Even outside of JWS, I wonder where/how this information is stored:
Hrmm…
I need to google for some more info in the morning…
And the next sentence after the one you quote is:
[quote]The user of this class needn’t be concerned with details of the backing store.
[/quote]
Anyway, just do something and abstract your code in such a way that you can change how preferences are manages easily and can do it some other way if you get complaints.
I’d rather not use it if I knew it was going to dump data in the system registry, for eample. And it would be good to know where a flatfile database would be created. Could this class hijack an SQL server that is running on a user if it allows anonymous access? Every option mentioned potentially has serious drawbacks
By this time, I could have written a test program. What a loser I am 8)
The default implementation on Windows will indeed use the registry to store preferences. I think on Linux a file-based solution is used. It should be possible (at the expense of more code to download, of course) to roll your own always-file-based solution.
I like the prefs package, it’s easy to use as-is and does what I want most of the time.
I think the answer to the question of “what does it do under Web Start” is that it depends upon what permissions your WS app has asked for.
If you’ve asked for full permissions and you’ve specified that your WS app needs 1.4 to run then you should be able to use any 1.4 API you desire. On the other hand, if you are not asking for permissions in your JNLP file then you are very restricted in what you can call. So you will probably have to use the WS mechanism for persistent storage. It is called muffins and is similar to the cookies mechanism that servers are allowed to use with browsers when they communicate via HTTP.
Personally, I’d rather use the 1.4 preferences stuff.