开发者

Single instance of a Java desktop application with argument passing

开发者 https://www.devze.com 2023-03-24 18:26 出处:网络
I\'d like only a single instance of my Java Swing application to run at a time. If a second instance is opened, I would like it to pass its arguments to the instance already running. How can I do this

I'd like only a single instance of my Java Swing application to run at a time. If a second instance is opened, I would like it to pass its arguments to the instance already running. How can I do this using a nice, clean Jav开发者_高级运维a API? (I'd prefer not to implement it myself using sockets or filesystem locks).

I've seen a number of solutions for enforcing a single instance in Java, but the only one I know of that passes arguments to the running instance uses JNLP's SingleInstanceService, and I'm not writing a Java web start application, so I can't use this (I got a NullPointerException when I tried).


See http://www.advancedinstaller.com/user-guide/single-instance-application.html


You can use launch4j to do this amongst a whole host of other things:

http://launch4j.sourceforge.net/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号