How to allow running only one instance of a Java program at a time?
I need to prevent users from starting my Java application (WebStart Swing app) multiple times. So if the application is already running it shouldn't be possible to start it again or show a warning / be closed again. Is there some convenient way to achieve this? I thought about blocking a port or write sth to a file. But hopefully you can access some system properties or the JVM? btw. target platform is Windows XP with Java 1.5 I think your suggestion of opening a port to listen when you start your application is the best idea. It's very easy to do and you don't need to worry about cleaning it