Feb 5, 2008

How to prevent multiple instances of an RCP Application?

The Eclipse IDE does this by obtaining lock on a file in the workspace. However, this method allows you to run multiple instances of the same IDE, each of them in a separate workspace.

In an RCP Application, if you follow the file lock mechanism, you need to get a lock on a well known file (like C:\Program Files\My App\instance.lock). Alternatively you can also prevent multiple instances by creating a server socket on some port (this method might alert Virus scanners/Firewalls)

There is no technique that is specific to RCP application, that is used to achieve this. You can use any Java application technique. You can Google around for more Java solutions and apply them in your RCP applicaiton.

0 comments: