Java programs (like all programs) require a CPU and memory to operate instructions. Both elements are complex electrical circuits, they cannot work without electricity.
The only thing you can do to persist the state of your application, is to write information regarding that state to disc. The Google File System uses this method to ensure not too much information is lost if one of their (usually inexpensive machines) goes down.
Short of this. No there is no way Java can handle a power out.
solved What happens to a Java program when you turn the power off?