0

I want a list of all running application in my java code.I got list of all the running processes by my code but I dont want that. I want only main Application. Like if two application are running in my pc then I should get only those application's Name.Please help me, its urgent.Any help will be appriciated.

Thanks in advance.

  • possible duplicate of [How to get a list of current open windows/process with Java?](http://stackoverflow.com/questions/54686/how-to-get-a-list-of-current-open-windows-process-with-java) – jhamon Aug 19 '14 at 09:13
  • Are you referring to threads when you speak of "running application in my java code"? Please edit your question and enhance your question so that it is understandable what you want to to and what you already tried. – Robert Aug 19 '14 at 09:14
  • I have checked the link you had given but using that I am getting the list of all Processes.but I want only main application list.like if notepad and windows media player is running in laptop then I should get the list that gives me those two names. – user1629968 Aug 19 '14 at 13:01

1 Answers1

0

You could try to open a specific file and lock it when your program starts. If another instance of the program starts and tries to lock the file, it will throw an exception. Here is an example of locking a file in Java.

http://examples.javacodegeeks.com/core-java/nio/filelock/create-file-lock-on-file/

Stanley Stein
  • 397
  • 1
  • 3
  • 17