How can I determine if the java running?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Attila_Roman
Posted On:   Wednesday, July 2, 2003 05:38 AM

Hi

My problem is: I want to stop the Java code if this code already running, with other words I don't want to allow to the same program to run in more than one exemplar.What can be the solution under Java?

Thanks,

Attila

Re: How can I determine if the java running?

Posted By:   Attila_Roman  
Posted On:   Wednesday, July 2, 2003 06:09 AM


try {
ServerSocket listenerSocket = new ServerSocket(8000);

} catch(java.net.BindException e) {
System.err.println("A previous instance is already running....");
System.out.println("Process finished");
System.exit(1);

} catch(final IOException e) { // an unexpected exception occurred

System.exit(1);
}




I find the solution....
About | Sitemap | Contact