0

I have made a java application exported as a runnable jar file. The user can customize it settings like for example how many textfields it shows. The default might be three textfields but the user might want to see 8 of them. The next time the user starts this application the number of textfields is going to be the default one: 3.

However I need a way to save his settings within the jar file itself.

What I already did is to have a .txt file which stores all the saved data. But this time the application has to be portable. So it has to be a all-in-one application without any other files around it.

Arjihad
  • 117
  • 7
  • You can't do that. The established way is to have a settings directory, and save the customized settings there. If it doesn't exist, you create and put the default settings there, or use the OS settings mechanism - see [an answer to a question about user preferences](https://stackoverflow.com/a/4580053/4125191). – RealSkeptic May 07 '19 at 09:46
  • 1
    @RealSkeptic why? `jar` file is simple `zip` file. You can write to it. Of course it is bad idea, but it is certainly possible. – talex May 07 '19 at 09:48
  • 1
    @talex - writing to the Jar your own application is currently holding open and running from is virtually impossible. You can write a new one. Modifying the existing one will end in a sea of troubles. There are many things that are theoretically possible, but are the wrong solution to the problem. – RealSkeptic May 07 '19 at 09:50
  • @RealSkeptic yes. It is exactly what I meant. – talex May 07 '19 at 09:52

1 Answers1

0

I know it is not helping but it is not possible. File system is the only way until you are working on remote app with multiple nodes.