Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dumping a Java program into a file and restarting it

Tags:

java

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

--- update -------

Yes, this is the hibernate feature for a process instead of a full system. But google 'hibernate jvm process' and you'll understand my pain.

There is a question for linux on this subject (here). Quickly, it's possible to hibernate a process (far from 100% reliable) with CryoPID.

A similar question was raised in stackoverflow some years ago.

With a JVM my educated guess is that hibernating should be a lot easier, not always possible and not reliable at 100% (e.g. UI and files).


Serializing a persistent state of the application is an option but it is not an answer to the question.

like image 917
ic3 Avatar asked Jan 26 '12 19:01

ic3


People also ask

What happens when you run a program in Java?

In Java, programs are not compiled into executable files; they are compiled into bytecode (as discussed earlier), which the JVM (Java Virtual Machine) then executes at runtime. Java source code is compiled into bytecode when we use the javac compiler. The bytecode gets saved on the disk with the file extension .


1 Answers

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

like image 76
Frankie Avatar answered Oct 08 '22 06:10

Frankie