Reputation: 15251
Is it possible to save the current state of the application before exit and next time the application starts, it will pick up right where you left off? Like literally a snapshot of previous session (sort of like VirtualBox save state feature).
Upvotes: 3
Views: 1329
Reputation: 718768
It is possible to persist the execution state of an application, but it requires the application to be written in a specific way to achieve this.
One approach is to use an implementation of continuations for Java. (Google "continuations java" for more information and pointers to Java libraries that support this.)
Another approach is to use object serialization. However, this only snapshots the heap data structures. Execution state on the thread stack(s), etcetera cannot be preserved this way.
There is no general purpose all-of-JVM or application checkpointing in any edition of Java.
Upvotes: 2
Reputation: 9
See if you can stick all of your variables and data into a class that implements Serializable - on JVM exit, store the data to a file. Once the program starts back up, load the data from the file and carry on. That's what I've done, I don't know if this will be adequate for your application.
Upvotes: 0