This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Save object fields data between runs  RSS feed

 
Alex Lucard
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone tell me how you get a java object to save the values in it's fields between restart without the use of a database or external file.
I created a GUI jar file that when runs will login into a server and pull a log file.
The GUI has text fields.
1) Server IP
2) Login ID
3) Password.
I would like it to keep my settings between runs.
The password expires every 14 days so I do not what to hard code it.
 
salvin francis
Bartender
Posts: 1603
35
Eclipse IDE Google Web Toolkit Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats a very odd requirement.

If you want some information to survive across a machine's restart, you need to save it somewhere.
Normally, it would be saved to a database or a file.

If thats not an option, maybe you can save it in a remote file or an external server via an http request ?
 
Campbell Ritchie
Marshal
Posts: 55717
163
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest you create a Settings object with those fields in; you can serialise it to a file or save it to a text file.
But you should not save passwords like that.
 
Alex Lucard
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will look into the serialise, But can you save the text file inside the jar file?
 
Paul Clapham
Sheriff
Posts: 22491
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alex Lucard wrote:But can you save the text file inside the jar file?


No.

So perhaps you wouldn't mind saving the data in a file but you don't know where you should put the file?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!