当我启动jar时,如何传递多个Nashorn参数?

时间:2021-07-21 01:06:52

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

当我启动一个jar时,我试图传递多个Nashorn参数,如下所示:

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

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

第二个Nashorn参数-t似乎没有被处理,我得到了这个:

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?

我猜它被认为是一个java参数,但这不是我的意图,我怎么能清楚地说明它是Nashorn参数而不是java参数?

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

注意:我使用的是java版“1.8.0_144”

1 个解决方案

#1


2  

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:

我不认为逗号分隔值有效。我查看了相关的nashorn源代码。它使用StringTokenizer和默认分隔符集(即“\ t \ n \ r \ n”)。以下是有效的:

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

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

请注意,使用-t选项时,必须传递时区参数。

#1


2  

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:

我不认为逗号分隔值有效。我查看了相关的nashorn源代码。它使用StringTokenizer和默认分隔符集(即“\ t \ n \ r \ n”)。以下是有效的:

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

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

请注意,使用-t选项时,必须传递时区参数。