Hello,
I have found that as written, the automator action shows an error message when exiting like:
The action "Run Shell Script" encountered an error: ""
There is a simple way to make that error stop happening, which is to add the following line to the end of the script block:
$r
I think the problem is we stored the result of the java command to a variable named r, but did not actually return that from the overall script.