Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to assure that one instance of Swing application running?  RSS feed

 
D Rog
Ranch Hand
Posts: 472
Linux Objective C Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a Swing application which is system tray iconizable. Sometime a user can miss it in system tray so makes an attempt to launch another copy. A correct behavior should be just restore a currently running version. I noticed some solution based on setting up a listener on some port and monitor already running instance. This solution doesn't look good, because Vista will warn a user about suspicious activity on a port. Another solution is using a file, however a previous insance can die without file removing. It isn't obvious how to send a message in another application to restore it as well. Accessing system mutex is requiring native call, so it doesn't acceptable. How do you solve a similar problem? I thought about independent server to manage all instances, however it will require internet access which isn't always available.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'd go with the port approach - it's the most workable solution, and Vista warning about suspicious activity isn't too bad - Vista "warns" the user about all kinds of stuff. Most people either completely turn off user access controls (because it's so annoying), or always click 'OK' (because they don't know how to turn it off).
 
D Rog
Ranch Hand
Posts: 472
Linux Objective C Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!