Any way to “reboot” the JVM?

后端 未结 8 1024
难免孤独
难免孤独 2020-12-05 17:46

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?

8条回答
  •  猫巷女王i
    2020-12-05 18:05

    AFAIK there is no such way.

    Notice that if there were a way to do that, it would highly depend on the current loaded code to properly release all held resources in order to provide a graceful restart (think about files, socket/tcp/http/database connections, threads, etc).

    Some applications, like Jboss AS, capture Ctrl+C on the console and provide a graceful shutdown, closing all resources, but this is application-specific code and not a JVM feature.

提交回复
热议问题