Are there any Java VMs which can save their state to a file and then reload that state?
Are there any Java VMs which can save their state to a file and then reload that state?
If so, which ones?
Another option, which may or may not be relevant in your case, is to run the JVM (any JVM) inside a virtual machine. Most virtual machines offer the option to store and resume state, so you should be able to restart your PC, fire up the VM when it comes back up and have the Java process pick up from where it was.
I use VMWare Player for testing on IE at work, and this works as noted above when I close and later reopen it. I don't generally do this when apps are doing anything of note in the VM, but as long as they aren't accessing any external resources (e.g. network sockets), I would expect it to work as if the VM was never shut down.
Continuations are probably be what you are looking for:
[...] first class continuations, which are constructs that give a programming language the ability to save the execution state at any point and return to that point at a later point in the program.
There are at least two continuation libraries for Java: RIFE continuations and javaflow. I know that javaflow at least allows serializing state to disk:
A
Continuation
can be serialized if all objects it captured is also serializable. In other words, all the local variables (including allthis
objects) need to be marked asSerializable
. In this example, you need to mark the MyRunnable class as Serializable . A serialized continuation can be sent over to another machine or used later. - Javaflow Tutorial