Dumping a Java program into a file and restarting it

后端 未结 10 978
温柔的废话
温柔的废话 2020-12-29 08:30

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

相关标签:
10条回答
  • 2020-12-29 08:44

    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.

    0 讨论(0)
  • 2020-12-29 08:49

    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.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-29 08:56

    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

    0 讨论(0)
提交回复
热议问题