0

I am trying to create a java standalone program and was wondering if there is a way to have some sort of data storage within my jar?

You see, my initial idea was to use xml files within the jar for reading and writing stuff in. I had no problem reading stuff from the xml files but I was told you cant really edit/create new files within a jar.

I want it so when i send the executable jar to my friend, initial data I have put in will be in it already and then they can just add to or change the data. I find it pretty tricky as it has to be a form of data storage without the internet access or any need for my friend to install anything more.

obsessiveCookie
  • 1,130
  • 2
  • 18
  • 33

2 Answers2

0

I decided to go for sqlite in the end. It works exactly how i want it to work. I might look into javaDB in the future as it seems to have better SQL language support sqlite.org/cvstrac/wiki?p=SqliteVersusDerby

obsessiveCookie
  • 1,130
  • 2
  • 18
  • 33
-1

As far as I know, JAR files are read-only, which cannot be rewritten to. My suggestion is to use MS Access database as your JAR's data keeper. As it is portable, the only weakness is that you have to bring both of your JAR and MDB files together (or put them in 1 folder).

A-SM
  • 882
  • 2
  • 6
  • 18
  • Hmm. Would my friend need to have MS Access installed in his pc? – obsessiveCookie Jun 02 '13 at 17:29
  • If you are going for an embedded DB solution, use JavaDB which has a small footprint and does not require any external/third-party SW or driver on the client (i.e. your friends' PCs) since it is implemented in Java. – gkalpak Jun 02 '13 at 20:09
  • it seems that he doesn't need to, because it is the JAR file which will access the MDB files. Not the Windows. @ExpertSystem: yes I think that's the best solution, I haven't try JavaDB so I don't know how it works. – A-SM Jun 02 '13 at 21:45
  • Thanks guys. I decided to go for sqlite in the end. It works exactly how i want it to work. I might look into javaDB in the future as it seems to have better SQL language support http://www.sqlite.org/cvstrac/wiki?p=SqliteVersusDerby – obsessiveCookie Jun 03 '13 at 23:02
  • Oh and @A-SM not so important but im a "she" – obsessiveCookie Jun 03 '13 at 23:04