I was just wondering if it\'s possible to dump a running Java program into a file, and later on restart it (same machine)
It\'s sounds a bit weird, but who knows
Probably Terracotta can this: http://www.terracotta.org
I am not sure but they are supporting server failures. If all servers stop, the process should saved to disk and wait I think.
Otherwise you should refactor your application to hold state explicitly. For example, if you implement something like runnable and make it Serializable, you will be able to save it.
I believe : 1- the only generic way is to implement serialization. 2- a good way to restore a running system is OS virtualization 3- now you are asking something like single process serialization.
The problem are IOs. Says your process uses a temporary file which gets deleted by the system after 'hybernation', but your program does not know it. You will have an IOException somewhere.
So word is , if the program is not designed to be interrupted at random , it won't work. Thats a risky and unmaintable solution so i believe only 1,2 make sense.
I guess IDE supports debugging in such a way. It is not impossible, though i don't know how. May be you will get details if you contact some eclipse or netbeans contributer.
This may me a bit overkill but one thing you can do is run something like VirtualBox and halt/save the machine.
There is also:
- JavaFlow from Apache that should do just that even though I haven't personally tried
it.
- Brakes that may be exactly what you're looking for