0

I have a javafx application that I packaged and installed on my pc.

The first launch of the application is working fine.

If I keep the application running, is there a way to handle the second launch of application to show the first one like skype for example ?

Thank you so much in advance

Update:

I tested the ManagementFactory example, it's only working on the IDE (I'm using netbeans) but when the application is installed(Windows 8), the class name and the command line are empty ! So the comparison is not good.

For the file locking, I'm already using this approch for protecting a file when the application is launched but it does not throw an exception when launching the second instance ! (Besides, on Oracle forum https://community.oracle.com/thread/2044019, they said if there is a power cut, the file will be still locked).

For server socket, I think it's not a good approch because it's a desktop application, so I can't guess which port is not used !

michael laudrup
  • 27
  • 3
  • 10
  • Without posting relevant code, no one can help you. Downvoting. You can refer how to ask a question by checking http://stackoverflow.com/help/how-to-ask and how to create an example by reading this : http://stackoverflow.com/help/mcve – We are Borg Sep 23 '15 at 14:40
  • Well, this kind of question does not require code, it's about an application installed on windows and I'm talking about managing the second instance of application at running time – michael laudrup Sep 23 '15 at 14:46
  • This requires code, as your app has to be programmed so it's not a Singleton. – We are Borg Sep 23 '15 at 14:49
  • There are several duplicates on Stackoverflow, eg.: http://stackoverflow.com/questions/177189/how-to-implement-a-single-instance-java-application http://stackoverflow.com/questions/19082265/how-to-ensure-only-one-instance-of-a-java-program-can-be-executed http://stackoverflow.com/questions/10508846/how-to-make-sure-that-only-a-single-instance-of-a-java-application-is-running – Puce Sep 23 '15 at 14:51
  • Thank you for the links, I've already seen most of them. Please check the update section. – michael laudrup Sep 23 '15 at 15:22

0 Answers0