First of all you must consider what will happen when you add records to your database if your database file is stored within your application jar.
I would recommend that your database file should be located somewhere else, but in the application jar. As a matter of fact, (and somebody please correct me if I am wrong), I do not believe you can modified the contents of a file stored in a zip format, like a jar. Now, even though your file is read-only I would consider to put it somewhere else.
That being said, there are plenty of options to solve this problem. The first is to put the file in the same directory of your jar.
Then simply:
FileInputStream("yourfile.db") Another option is to pass the path to the directory of the database file in the
java application launcher classpath:
java -cp myjar.jar; /home/obiwan/database/ Then simply:
InputStream in = ClassLoader.getSystemResourceAsStream("data.db"); Or you could pass the path to your file at the application start up
java -jar myJar.jar /home/obiwan/database/jedis.db Or you could save the path to your file in a properties file and get it from it, or you ask in the GUI the path to the file (like in MS Access database).
Do any of these sound useful?
[ June 06, 2006: Message edited by: Edwin Dalorzo ]