only one instance



I want only one running instance of my app.

There are 2 methods:

1. sockets
2. locking files (I prefer this)



But my big problem is this:

When I run the 2nd instance of App with a file parameter:

my_app.jar  a_file.txt

I want to pass "a_file.txt" to 1st instance for opening and then 2nd instance terminate.

How can I do this?


sorry for my english and thanks .