How can I pass multiple Nashorn arguments when I launch a jar?

457 views Asked by At

I am trying to pass multiple Nashorn arguments when I start a jar, something like this:

java -Dnashorn.args=-scripting -t -jar myjar.jar

The second Nashorn argument -t doesn't seem to be processed, and I get this:

Unrecognized option: -Xt
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

I guess it was considered to be a java argument but that was not my intention, how can I clearly state that it's a Nashorn argument and not a java one?

Note: I'm using java version "1.8.0_144"

1

There are 1 answers

0
A. Sundararajan On BEST ANSWER

I don't think comma separated values work. I looked at the relevant nashorn source code. It uses StringTokenizer with the default delimiter set (which is " \t\n\r\f"). So the following works:

java -Dnashorn.args="-scripting -t=Asia/Calcutta" -jar myjar.jar

Note that with -t option, a timezone argument has to be passed.