Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
    Bookmark Topic Watch Topic
  • New Topic

Running Single Instance of application

 
satyam vizag narayana
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi,

I developed a swing based application in java. I am running it through the executable jar. Each time clicking on the jar file it opens the new instance of the appliction.

But I want to open the single instance of the application i.e. If the application is running , then user tries to open another instance it should be display the error or running application only like yahoomessenger,notepad,etc.

Please tell me how it is done in java. send aly sample code or resources regarding this.

Thanks
in advance
 
aslam parveez
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Report post to moderator
I dont know what kind of application you are talking about.

One way of doing it is , Create a ServerSocket object just before your window is made visible.
For ex: ServerSocket serverSocket=new ServerSocket(5555);

If the application is already running and if you try to run it again then typically you should get an error saying "Port already in Use".
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please don't post the same question in multiple forums. It creates duplicate conversations and wastes the time of the people trying to help you.

Thanks,
Dave
 
    Bookmark Topic Watch Topic
  • New Topic