There is no need for another thread. The ServerSocket is all that is needed to test for another program using the port. Remove the accept() call.
Type: Posts; User: Norm
There is no need for another thread. The ServerSocket is all that is needed to test for another program using the port. Remove the accept() call.
Please copy the full text of the error message and paste it here. It has important info about the error.
Look at the Runtime class's addShutdownHook() method.
Have you tried the file method across reboots of the system? Can the file be left when the system reboots?
Do you have a solution now? It works for me. First execution puts icon in tray. Next executions print already in use message.
What happened when you created a test program that used the ServerSocket when you started the program for the second time?
If you only want one version of a program running at a time, then the program needs to detect when another version has been started. One way is to use a ServerSocket at a special port to detect the...