• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to assure that one instance of Swing application running?

 
Ranch Hand
Posts: 472
Objective C Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Objective C Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.
 
He repaced his skull with glass. So you can see his brain. Kinda like this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic