How to implement a single instance Java application?

后端 未结 17 788
北荒
北荒 2020-11-22 04:32

Sometime I see many application such as msn, windows media player etc that are single instance applications (when user executes while application is running a new applicatio

17条回答
  •  太阳男子
    2020-11-22 04:47

    I used sockets for that and depending if the application is on the client side or server side the behavior is a bit different:

    • client side : if an instance already exists(I cannot listen on a specific port) I will pass the application parameters and exit(you may want to perform some actions in the previous instance) if not I will start the application.
    • server side : if an instance already exists I will print a message and exit, if not I will start the application.

提交回复
热议问题