• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Save object fields data between runs

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ?
 
Marshal
Posts: 79180
377
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I will look into the serialise, But can you save the text file inside the jar file?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
reply
    Bookmark Topic Watch Topic
  • New Topic