• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to interect between two JVM instances?  RSS feed

 
Girish Vasmatkar
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello to all ranchers,

My desktop application is a JFrame and I want only one instance of my application to run at a time and so far i have been successful.

I used file locking mechanism to check if the lock on the file exists and it it does exists then I am stopping another instance of JFrame to load.

But when I minimize the first instance i want that first instance of JFrame to be maximized or you can say setVisible(true).

Does any one have any idea how can i do this?

Thanks
 
Peter Lawrey
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of using a lock you could have them communicate using Sockets.
You can start the first one as a Server on a fixed port, and a second will not be able to start on that port until the first one dies. You can have these processes communicate via this port as well.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!