jreid42
jreid42

Reputation: 1250

Open a file in a running java jar

If I have a jar file that is running, what is the best way for it to handle the opening of launched files to it - is there any cross platform way of doing this or would I have to make it a native application via something like JSmooth first (would like to avoid as much as possible)?

Say the jar file is running and is associated with text files; when I open a text file I want it to open up in a running instance.

I'm guessing I would have to check to see if the jar is running; but how do I do this in JAVA?

If I do find the jar is running what communication method would be best to tell the running instance to open the file?

Upvotes: 3

Views: 370

Answers (1)

Beothorn
Beothorn

Reputation: 1317

Open a socket and check everytime you open an application if it's already running. If it is just send the file location to the instance already open and close the duplicated one.

Upvotes: 1

Related Questions