some of the applications use configuration files to do this.
like if an application is run it puts an entry in a file and when it is closed the entry in the file is removed.
one more way is to use windows registry(since java has registry support) but i don't know how it would behave on other platforms.
every time the user runs the application checks for these entries.
whatever the case but this is not fail-safe. if some exception occurs and user exits the application from task manager, the entry is left behind. so always give the user an option even if the application thinks its already running.