开发者

Single instance of a Java desktop application with argument passing

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜