Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to "reboot" the JVM?

Tags:

java

jvm

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?

like image 707
Alex Avatar asked Nov 03 '08 17:11

Alex


People also ask

Can we restart JVM?

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.

How do I manually start JVM?

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.

How do I start and stop JVM in Linux?

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.


2 Answers

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.

like image 193
Andru Luvisi Avatar answered Oct 14 '22 06:10

Andru Luvisi


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.

like image 25
DustinB Avatar answered Oct 14 '22 08:10

DustinB