Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use java.exe when --headless and --run are set #47

Open
stelfrich opened this issue Nov 27, 2017 · 5 comments
Open

Use java.exe when --headless and --run are set #47

stelfrich opened this issue Nov 27, 2017 · 5 comments

Comments

@stelfrich
Copy link
Member

At least on Windows 10 (haven't tested other versions) the following call will not return even if the Jython script exits:

$ .\ImageJ-win64.exe --ij2 --headless --console --run someScript.py

The problem can be remedied by using java.exe instead of javaw.exe in the aforementioned configuration. That is, I would expect the ImageJ process to exit when a script that I execute with --headless --run exits.

See also:

@ctrueden
Copy link
Member

The launcher, unless it is "falling back to system java", does not use java.exe nor javaw.exe at all. Rather, it dynamically links to the JVM shared library. The --console flag, if I understand correctly, is supposed to attach to the win32 console; see the open_win_console method in platform.c. See also #29 for related discussion.

@sebi06
Copy link

sebi06 commented Nov 28, 2017

Hi guys,

this is really beyond my expertise, but on my windows system the usage of

ImageJ-win64.exe --dry-run --ij2 --headless --console

generates the following output:

javaw -Dpython.cachedir.skip=true -Dplugins.dir=FJD -Xmx8000m -Djava.awt.headless=true ...

This cause the described issues in:

http://forum.imagej.net/t/need-help-with-exiting-python-script/7832/8

And when I change javaw against java the issue is gone. So what exactly is changed when using one vs. the other. My Fiji comes with its own java located in c:\Users\Public\Documents\Fiji\java\win64\jdk1.8.0_66\jre.

Let me know, if I can be of any further help.

@ctrueden
Copy link
Member

@sebi06 Thanks for your comment. Indeed, javaw.exe and java.exe are different. However, the --dry-run flag produces only a best-effort approximation of what the launcher does normally. As I said above, the launcher normally does not invoke either of those two executables, but rather links against a shared library.

I am sorry, but I am far from a Windows expert, and do not have time to troubleshoot this issue this year. If someone who knows the Windows native environment would care to file a PR against the ImageJ launcher, though, that would certainly be appreciated.

In the meantime, invoking java.exe directly with the requisite command line flags is probably your best bet.

@LauLauThom
Copy link

If you remove the --console argument, the command line returns to a new feed. But right after pressing enter, not once the script execution is over.
Yet when calling fiji this way from an external program, the external program indeed detected the end of the execution. I don't know though if you can recover what was printed to the console in the external program (maybe using an output file would be a safer option).

@stelfrich
Copy link
Member Author

Another report of a similar issue (that I'll leave here for reference): https://forum.image.sc/t/console-application-doesnt-exit/19791/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants