New on the forum. Working on Win 10 with intelliJ. Java 8 and Javafx
I have a softphone, written in java. It is wrapped to an exe with launch4J.
Now I want to implement click to call, so I have a link on a site that opens up my program and makes the call (if main is called with arg, check if it is valid and make the call). Works like a charm.
My main method gets called with the proper 'tel:number' and starts OK.
But I really just want one instance of the program running, so my question is:
If the phone is already lauched, what is the best way to start the call? Is it the exe that must be configured in some way?
I have launch4J configured to admit ONE instance.
Is JMI the way to go? Config the exe main?
Thanx in advance for any tip!
Asked
Active
Viewed 204 times
0

Hans Bragman
- 1
- 2
-
sounds like you want interprocess communication. using sockets might the easiest approach. – BevynQ Jul 19 '16 at 09:20
-
You have to configure your executable so that only one instance runs http://stackoverflow.com/questions/177189/how-to-implement-a-single-instance-java-application – Chamindu Jul 19 '16 at 09:20
-
So I should make launch4J admit several instances and handle that in the java code, like the link suggests? Open a socket first time, and if creating socket fails, send the args to the socket, and close (the new instance)? Sounds doable.. Any other suggestions? – Hans Bragman Jul 19 '16 at 09:41
-
And since I was so eager to try, forgot to say Thanx alot! – Hans Bragman Jul 19 '16 at 13:59
-
It became a hassle to make the threads running the sockets work with javafx. Even if that is possible to get through, I settled with identifying pid's and writing the tel command to file. Works good on windows, but getting the tel command to start and call (or make an started phone to call) on Mac will be a problem. Mac insists on intercepting the command and trying to start FaceTime or iPhone, even though I have set my phone as preferred on tel commands. Maybe another thread for this ;) – Hans Bragman Jul 22 '16 at 08:26
-
On Mac I settled for using a AppleScript as a wrapper for the app. This script has two methods, one for listening for double-clicks and one for openLocation events. And then starting the program with or without the arg given from openLocation. Not the easiest way perhaps? Since I determine if the app is rolling in the main method, this means the program is started before terminated (in case another instance is rolling). I would rather used the classes that can intercept apple events but it would not work.. :( – Hans Bragman Oct 05 '16 at 15:06