Refresh Javas: be nice in headless mode

There is no use trying to show a text window when in headless mode,
even if there was a compile error. So show an exception instead,
which is automatically redirected to stdout in headless mode.

Noticed while debugging with Curtis Rueden.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>