Java: is it possible to save jvm state and restore after application restart?

Is it possible to save the current state of the application before exiting and the next time the application starts, it will take you back to where you left off? Like literally a snapshot of the previous session (like VirtualBox's persistence function).

+3


source to share


2 answers


It is possible to save the execution state of an application, but this requires the application to be written in a certain way.

  • One approach is to use the Java continuation implementation. (Google "java sequels" for more information and pointers to Java libraries that support this.)

  • Another approach is to use object serialization. However, these are only snapshots of the heap data structures. Execution state on the stack of stacks, etc. Can't be saved that way.



There is no overall JVM target or application checkpoint in any Java edition.

+1


source


See if you can inject all your variables and data into a class that implements Serializable - in the output of the JVM, store the data in a file. Once the program starts, load the data from the file and continue. What I did, I don't know if this would be the right fit for your application.



0


source







All Articles