Prevent launching multiple instances of a java application

前端 未结 10 2146
你的背包
你的背包 2020-12-03 03:19

I want to prevent the user from running my java application multiple times in parallel.

To prevent this, I have created a lock file when am opening the application,

10条回答
  •  孤街浪徒
    2020-12-03 03:48

    You can write something like this.

    If file exists try to delete it. if it is not able to delete. We can say that application is already running.

    Now create the same file again and redirect the sysout and syserr.

    This works for me

提交回复
热议问题