简体   繁体   English

JVM崩溃时如何重启Java程序

[英]How to restart java program if JVM crashes

I am working on a very low configuration machine , where JVM crashes sometimes. 我正在配置非常低的机器上,JVM有时会崩溃。

The java application name is application.jar, which plays HD Video from local streaming servers. Java应用程序名称为application.jar,可播放来自本地流服务器的高清视频。 This application is running on a embeded win7 touch computer, which is hanged in a lounge. 此应用程序在挂在休息室的嵌入式win7触摸计算机上运行。

Some time the heap size exceeds and the error is out of memory the the JVM shuts down. 一段时间堆大小超过并且错误内存不足,JVM将关闭。

I want to restart my application.jar whenever JVM crashes. 每当JVM崩溃时,我都想重新启动application.jar。

It is possible. 有可能的。 Then how? 那怎么办

Thanks. 谢谢。

Edit: wrapping with try catch does not work as jvm crashed. 编辑:尝试捕获包装不起作用,因为jvm崩溃了。 I also have used -Xms512m -Xmx1024m while running the jar file. 在运行jar文件时,我还使用了-Xms512m -Xmx1024m。 the crash frequency is got lower but still it remains. 崩溃频率降低了,但仍然存在。

If really need auto restart you can wrap your application with demonization tool like daemon . 如果确实需要自动重启,则可以使用守护程序(例如daemon)包装应用程序 It has --respawn parameter. 它具有--respawn参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM