I have used a static variable in a Class and I want that the value of this variable is kept unchanged after restart of the jvm. The idea is to store this value. Can someone help me ?
Asked
Active
Viewed 1,846 times
0
-
2Typically you would use a relational database for this. – Tim Biegeleisen Jun 28 '19 at 10:55
-
2Simply read it from DB or persist to a file or serialize your class – Vinay Prajapati Jun 28 '19 at 10:56
-
2Use external datasource. Database, file.. – Ruslan Jun 28 '19 at 10:56
-
There is no a local storage in java for example ? – Im89 Jun 28 '19 at 11:02
-
What do you want this static variable to be @Im89 do you just want something constant, as to say when you reboot the program it will be the same value? – Luke Garrigan Jun 28 '19 at 11:03
-
@LukeGarrigan i want to keep the same value when i reboot the program – Im89 Jun 28 '19 at 11:04
-
1I suspect you are just wanting a constant, take a look at https://stackoverflow.com/questions/66066/what-is-the-best-way-to-implement-constants-in-java – Luke Garrigan Jun 28 '19 at 11:05
1 Answers
0
You restart the jvm every thing will be clear.So you can't get the values from static variables. If you use database then only you get the values without failing.

Sana
- 360
- 3
- 13