Not returning from Javascript macro in headless mode

Note: Just saw this same question (was not there when I started drafting my question over the weekend). Pretty much a duplicate.

I am setting up to run some batch processing on a linux cluster using headless mode. I can successfully run a test script, and also output to stdout with the print statement. However, the function doesn’t return. I tried exit(); but got:

ReferenceError: "exit" is not defined. (line#12)

I also tried throw("not an error...just want to quit");. The error message displays, but the function still doesn’t return.

arg_test.js

arg = getArgument();

if (arg=="")
{
        print("No argument!");
}
else
{
        print("The argument is: " + arg);
}

Output:

balter@WorkVDI:~/Documents$ ./fiji --headless -macro arg_test.js
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
No argument!
<CTRL-C>
balter@WorkVDI:~/Documents$ 
balter@WorkVDI:~/Documents$ ./fiji --headless -macro arg_test.js hello
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
The argument is: hello

How do I get the script to return? Do I need to appeal to a Java method? Also, do I need to worry about the warnings?

3 posts were merged into an existing topic: Headless macro does not exit after finishing