Opening one application at a time

I used RMI inorder to avoid opening two window for an application. But in some machines it is not working. All the port numbers seems to be busy . What should i do?
[171 byte] By [haishaia] at [2007-10-3 2:50:17]
# 1

Just open a server socket when launching application, something like this :

private static ServerSocket servSocket = null;

private static void checkMultipleInstance(){

try{

servSocket= new ServerSocket(20002);

}

catch(Exception e){

System.out.println("An instance is already running");

System.exit(0);

}

}

serghei1a at 2007-7-14 20:39:07 > top of Java-index,Desktop,Developing for the Desktop...
# 2
You could write a kind of lock file in the users home folder or temp folder and use the file path in the second app instance to detect that an instance is already running.
JMembera at 2007-7-14 20:39:07 > top of Java-index,Desktop,Developing for the Desktop...