How to allow running only one instance of a Java program at a time?

前端 未结 9 2243
南旧
南旧 2020-11-30 00:07

I need to prevent users from starting my Java application (WebStart Swing app) multiple times. So if the application is already running it shouldn\'t be possible to start it

9条回答
  •  孤街浪徒
    2020-11-30 00:33

    As the question states that WebStart is being used, the obvious solution is to use javax.jnlp.SingleInstanceService.

    This service is available in 1.5. Note that 1.5 is currently most of the way through its End Of Service Life period. Get with Java SE 6!

提交回复
热议问题