Send a file to ImageJ from the Windows command prompt without opening a new instance

I am using an R package (EBImage) on Windows to process image files and save to a ‘.tiff’ file. I want to then automatically open that file in ImageJ for viewing. To do this, I send a message to the command prompt to open the file using imageJ as below:

> ImageJ-win64.exe -file-name example.tiff

This works, and opens the file in ImageJ as I want. The problem is that this command will open a new instance of ImageJ even if there is one already running. So if I open 5 images in this way, I end up with 5 separate instances of ImageJ running. Crazy!

How can I avoid opening a new ImageJ with each file?

EDIT: To clarify, I do not want to open ImageJ in headless mode. I want to open the full program with all the tool-bars etc. The purpose of using this command is so I can automate opening files for viewing on screen.

Could you check whether you have actived Run single instance listener in Edit > Options > Misc…?

I did a quick test on my system (Windows 7) and noticed that running ImageJ-win64.exe will open a new instance every time, but running fiji-win64.exe re-uses the current instance. So far I was under the impression that both launcher are supposed to be equivalent, but now I’m not sure what’s the difference. I didn’t try with a freshly downloaded Fiji/ImageJ though.

Maybe @hinerm or @ctrueden can comment this.

1 Like

Yeah I think I broke single-instance listener with the last release. It was causing “Fiji won’t quit” issues because it wasn’t cleaning up after itself, and it was causing some unit test issues as well. I will look into it.

Thank you both. Yes I did have the single instance listener open, though swapping to the fiji-win64 installer from an earlier installation and it has solved the problem.

This issue should be fixed in the next release.


Thanks, that’s very helpful.

Available now via Help > Update... with the Java 8 update site.

1 Like