Main page > Software

Java: MultipleInstanceChecker

With some applications it may be useless or even dangerous to run more than one instance at the same time. This class helps a Java application to determine if another instance is running already. It does so by trying to reserve a server socket for a given port. If the server socket can be reserved, this instance is the first one. Otherwise a user-defined byte signature is sent to the running instance, which can then perform some action (e.g. bring its own window to the front of the desktop).

Usage

Study the MultipleInstanceTest application that comes with this class in order to find out how to integrate the check in your own application.

Download

MultipleInstanceChecker.zip (8 KB).