imagej / imagej-launcher

The ImageJ native launcher
https://imagej.net/learn/launcher
BSD 2-Clause "Simplified" License
21 stars 23 forks source link

Use --console logic automatically on Windows #29

Open ctrueden opened 9 years ago

ctrueden commented 9 years ago

In many scenarios on Windows, it is necessary to pass the --console flag so that the console it attached correctly. Otherwise, no output will ever been shown.

This flag is unfortunate, and it would be best if we could get rid of it completely. But barring that, let's at least be smarter about automatically enabling the console attach feature in circumstances where it is known to be necessary, such as with --headless.

See also #10, #11.

dscho commented 9 years ago

undocumented --console flag

https://github.com/imagej/imagej-launcher/blob/3e061521a554e4786eebcb6397ee77bb69396703/src/main/c/ImageJ.c#L1067-L1072

dscho commented 9 years ago

let's at least be smarter about automatically enabling the console attach feature in circumstances where it is known to be necessary, such as with --headless

When ImageJ is called from background processes, as is the case when using pseudo cluster software to make use of otherwise unused machines, the console is definitely not to be attached.

Worse, the reason to introduce the --console flag was that trying to attach a new console would open a new console if none was found. Totally undesirable behavior.

Thus, while this ticket was certainly well-intentioned, the problems are much, much harder than the report anticipates.

ctrueden commented 9 years ago

@dscho Sorry for the "undocumented" comment—I ran with --help on my Mac and didn't see the option, so I made an ass out of U and me.

Thanks for explaining some of the difficulties if the situation is to improve. So it seems research will be needed into how to robustly avoid violating the Least Astonishment Principle in various circumstances. Quick searches seem to indicate it might be possible to attach a console without necessarily creating one (e.g., this API call in C++ purports to do so).

teknowledgist commented 7 years ago

I feel compelled to comment that (in Windows) including the --console flag appears to only (mostly) work with the downloads that include Java and not with system-installed Java. (All I tested was the --update flag though.)

For example, --update --console with the ImageJ or Fiji-noJRE downloads returns nothing except Warning: falling back to system Java. Using the same flags with the normal Fiji download returns the full list of update subcommands.

In all cases, the console appears to be waiting for the command to finish (with a blinking cursor at the far left and no empty prompt appearing). In actuality, the prompt is "invisible". I can type commands and they run (upon enter), or tab through the files in the directory. The normal prompt returns on enter.

Also, the output to the cmd window must not be standard output because it doesn't redirect (e.g. to a file).

ctrueden commented 7 years ago

@teknowledgist Thanks, I have noticed some similar behaviors, and agree it is suboptimal, but I have neither the bandwidth nor particular expertise to fix it. Feel free to dig into the code. It should be pretty straightforward to make changes to the source, then rebuild and test using ./build.