configurar el directorio de la base de datos

I am working on a Java Desktop program which upon its installation will designate a default database directory and working directory. Where should I save such information so that the next time the user open the program, the program knows where to look for database and working directory?

Cosas que me vienen a la mente:

  1. store everything in the registry (well, did that in MATLAB version and if there is another way, definitely will not go there).
  2. set up another database attached in the jar file to store everything
  3. Is this a so called persistence problem? What are Java Persistence or Java Data Object? Do they have the way to make it working?
  4. ¿cualquier otra sugerencia?

preguntado el 08 de noviembre de 11 a las 17:11

3 Respuestas

Echa un vistazo a la API de preferencias de Java. It is a standard Java SE mechanism for storing preferences that does so in a platform specific, but application neutral way. Uses the Registry on Windows, Preferences files on OS X, and I believe ~/.files on Unix.

respondido 08 nov., 11:21

El Preferencias class was created to store things like... preferences in an OS-neutral fashion.

You could also just specify a directory location manually, through a launcher script, or create a default directory in the user's home, and keep both configuration and DB files there.

respondido 08 nov., 11:21

Your persistent memory is your hard drive, of course, so you need to store data there if you want it to persist from execution to execution. Really, anything goes. You could store the configuration in an XML file -- makes it user-readable outside of the application, which is really nice for debugging, and Java comes with libraries for XML parsing and generation. It would be OS-independent, unlike a registry solution, which is Windows specific. And you could use the XML approach to share information between apps, if that matters. Something to consider.

Actualizar: Preferencias are cool! Never saw that one before.

respondido 08 nov., 11:22

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.