Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 Java 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).

like image 689
peskal Avatar asked Aug 03 '11 13:08

peskal


1 Answers

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

like image 126
Vlad Avatar answered Oct 20 '22 18:10

Vlad