Skip to content
Advertisement

Java method to save current state of a program

Is it possible to save the current state of a java program and then reload it? The program is fairly complicated. I just need to be able to save the current state to a file and then reload it. Could you please refer me to a java library or a place to read more about that from.

Advertisement

Answer

There is no real way to “store the state of the whole JVM” as such.

But you could encapsulate the relevant state of your application in one or more objects and then serialize those objects. That sounds more complicated than it really is, because most likely the state of your application is already (mostly) encapsulated in some objects.

This serialization tutorial provides more information, for more details see the Java Object Serialization Specification.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement