Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open a file in a running java jar

Tags:

java

file

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?

like image 654
jreid42 Avatar asked Feb 26 '26 08:02

jreid42


1 Answers

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.

like image 199
Beothorn Avatar answered Feb 27 '26 20:02

Beothorn



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!