This discussion is archived
2 Replies Latest reply: Feb 5, 2013 12:12 AM by 802349 RSS

Have only 1 instance of a program running

802349 Newbie
Currently Being Moderated
When my Java program is running and I execute the same program again, I'd rather have the GUI of the running program show up instead of spawning a 2nd process. Can anyone help me with that? Thank you very much!
  • 1. Re: Have only 1 instance of a program running
    Kayaman Guru
    Currently Being Moderated
    user8995776 wrote:
    When my Java program is running and I execute the same program again, I'd rather have the GUI of the running program show up instead of spawning a 2nd process.
    Why would you run it twice if you want to run it only once?

    You could for example create a .pid file in *NIX style, to see whether the program is already running or not.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
  • 2. Re: Have only 1 instance of a program running
    802349 Newbie
    Currently Being Moderated
    Thanks, but when someone kills the application, the file remains.

    Found a solution here:

    http://www.rbgrn.net/content/43-java-single-application-instance

    If anyone knows a better approach, please let me know.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points