hi all,
how to detect program is running in my computer.
etc: i have open my program application name is myProgApp, in computer jhon, so if i open again the program that in computer jhon will show message 'file already open' .
thanks, for your help.

I am assuming here that you are talking about your Java application. When starting the application, bind it to any port which is not currently in use. That way when you try to create another instance of your application, you would get a socket exception saying that he port is already in use.

Something like:

import java.net.*;
import java.io.*;

public class SingleApplicationInstance
{
    public static void main(String args[])
    {
        try
        {
            ServerSocket ss = new ServerSocket();
            ss.bind(new InetSocketAddress(100));
            System.out.println("Application started");
            Thread.sleep(1000000000);
        }
        catch (SocketException e)
        {
            System.out.println("Application already running");
            System.exit(1);
        }
        catch(Exception e)
        {
            System.out.println("Application encountered some problem.");
            System.exit(1);
        }
    }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.