posted 21 years ago
Hi Tiamo,
A quick and dirty solution would be to open a ServerSocket on some free (hard encoded) port. Then any new instance would throw a BindException upon trying to open the same port. You can just catch the BindException and print a message in the catch block that only one instance may run and gracfully exit. Even if the program crashes, then the port should eventually be freed by the system.
Hope this helps,
Michael Morris
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher