storing data with executable JAR

if I have an executable JAR that needs to read and write from a text file so that users can customize the program, can I put the text file or any kind of database inside the JAR or does it have to go outside. Also, what is the best way to store such data, in a database or in a text file?

[295 byte] By [JFrustrationa] at [2007-11-27 11:05:31]
# 1

> if I have an executable JAR that needs to read and

> write from a text file so that users can customize

> the program, can I put the text file or any kind of

> database inside the JAR or does it have to go

> outside.

I think it's safe to say that you'd need to create a folder to keep your files in. i.e. the Jar won't get updated.

> Also, what is the best way to store such

> data, in a database or in a text file?

Depends, a small amount of simple data should go in a flat file, .txt is fine, whatever. If you have lots of (possibly complex) data and relationships between the data, etc. then you'd likely use a database.

SoulTech2012a at 2007-7-29 13:09:16 > top of Java-index,Java Essentials,Java Programming...
# 2

what is the simplest database that java can deal with? can it use an access, or open office database?

JFrustrationa at 2007-7-29 13:09:16 > top of Java-index,Java Essentials,Java Programming...
# 3

> what is the simplest database that java can deal

> with? can it use an access, or open office database?

Access, oh, puhlease! Check out hsqldb, the 100% Java database:

http://hsqldb.org/

Hippolytea at 2007-7-29 13:09:16 > top of Java-index,Java Essentials,Java Programming...
# 4

thanks Hippolyte, but just for heck of it, does java provide support for access in its API?

JFrustrationa at 2007-7-29 13:09:16 > top of Java-index,Java Essentials,Java Programming...
# 5

> thanks Hippolyte, but just for heck of it, does java

> provide support for access in its API?

Yes, through the JDBC, if you have an appropriate driver.

Hippolytea at 2007-7-29 13:09:16 > top of Java-index,Java Essentials,Java Programming...
# 6

I've used some simple object databases (like Cloudscape) that are really simple. I'd personally use MySQL.

SoulTech2012a at 2007-7-29 13:09:16 > top of Java-index,Java Essentials,Java Programming...