for me, your suggestion works in desktop mode, but not in batch mode.
The issue seems to be that for some reason the same workflow throws an exception in batch mode, with the following error:
WARN KNIME-Worker-1-Java Snippet 0:1660 JavaSnippetCellFactory Evaluation of java snippet failed for row "Row0".The exception is caused by line 33 of the snippet.
line 33 is: JOptionPane.showMessageDialog(null, "Your workflow is finished!!! :-)");