Is there any way to reboot the JVM? As in don't actually exit, but close and reload all classes, and run main from the top?
To restart the JVM, complete these steps: Stop any running servers under the WebSphere profile where a NoClassDefFoundError error message appears in the logs. Go to the JVM_profile_home \bin directory on Windows systems or the JVM_profile_home /bin directory on Linux and UNIX systems. Run the command OsgiCfgInit.
To start up JVMs manually, use the EXEC CICS or CEMT PERFORM JVMPOOL command. You need to specify the number of JVMs to be started, and the JVM profile and execution key that is to be used for them.
If the shell (command prompt) in which you start the server is still open, you can type Ctrl-C . On a Windows computer, you can use the Task Manager to kill a JVM. On a UNIX computer, you can use the ps command to list all running processes. Then you can use the kill command to kill the JVM.
Your best bet is probably to run the java interpreter within a loop, and just exit. For example:
#!/bin/sh while true do java MainClass done
If you want the ability to reboot or shutdown entirely, you could test the exit status:
#!/bin/sh STATUS=0 while [ $STATUS -eq 0 ] do java MainClass STATUS=$? done
Within the java program, you can use System.exit(0) to indicate that you want to "reboot," and System.exit(1) to indicate that you want to stop and stay stopped.
IBM's JVM has a feature called "resettable" which allows you to effectively do what you are asking.
http://publib.boulder.ibm.com/infocenter/cicsts/v3r1/index.jsp?topic=/com.ibm.cics.ts31.doc/dfhpj/topics/dfhpje9.htm
Other than the IBM JVM, I don't think it is possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With