Java method to save current state of a program
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.
The "state" of a java program is a complex beast. This would include the complete heap, the execution point of all threads, values of local variables ...
Most probably you just want to store some state and later load this in a new program. You could use the classes in java.io
to write state to files and later read them again.
http://download.oracle.com/javase/7/docs/api/java/io/package-summary.html