• Post Reply Bookmark Topic Watch Topic
  • New Topic

JAR - SWING - based problem  RSS feed

 
janne jounivich
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I would appreciate very much if you could give me some clue to solve the following problem I have.

I have built a JAR file that simply opens the JFrame window when clicked the JAR file. So far everything is ok (JAR file get correctly opened) but I am wondering how it could be possible to prevent (block) a user from having one or several instances of one and the same JAR application? This is now possible when user have clicked once my Jar app and having it opened, clicks another time the Jar app etc and finally there will be dozens of windows at one time.

What could be the best and nicest way of resolving this problem?

p.s Hopefully you all have understood correctly my problem?

Thanks in advance,
JRockGulf
 
Khan Malamir
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a common problem - ensuring that a single application instance is running. The solution is usually to provide a lock that all instances of your application will try to obtain when executed and if it is already locked - then an instance is already running.
Examples of these locks could be lock files or sockets. Be careful to ensure that the lock is released when application exits/crashes.
 
janne jounivich
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Khan. I got the point.

janne
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!