Restrict multiple instances of an application in java

前端 未结 8 1099
温柔的废话
温柔的废话 2020-12-03 22:55

I want to prevent multiple instances of application being launched in java. I know 2 methods for this:

  1. locking file
  2. locking socket

But

8条回答
  •  眼角桃花
    2020-12-03 23:10

    File lock is better way to do- imo. When you create the file in User's Home directory, this will still work in a multi-user environment.

    I came across - JUnique - haven't had a chance to use it http://www.sauronsoftware.it/projects/junique/manual.php

提交回复
热议问题