Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/393.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/variables/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我是否可以将参数传递给外部Beanshell脚本(来自另一个Beanshell脚本)?_Java_Scripting_Beanshell - Fatal编程技术网

Java 我是否可以将参数传递给外部Beanshell脚本(来自另一个Beanshell脚本)?

Java 我是否可以将参数传递给外部Beanshell脚本(来自另一个Beanshell脚本)?,java,scripting,beanshell,Java,Scripting,Beanshell,我试图弄清楚如何将参数传递给从初始脚本调用的第二个脚本。Beanshell文档中没有提到这一点。有人知道怎么做吗 // Start.bsh import bsh.Interpreter; Interpreter i = new Interpreter(); i.source("Target.bsh"); //Target.bsh System.out.println(“参数数量为:“+args.length”); for(int i=0;i

我试图弄清楚如何将参数传递给从初始脚本调用的第二个脚本。Beanshell文档中没有提到这一点。有人知道怎么做吗

// Start.bsh
import bsh.Interpreter;
Interpreter i = new Interpreter();
i.source("Target.bsh");

//Target.bsh
System.out.println(“参数数量为:“+args.length”);
for(int i=0;i
AFAIK,您不能通过
i.source(“file.bsh”)
传递命令行参数。您需要执行以下操作:

Interpreter i = new Interpreter();
NameSpace ns = i.getNameSpace();
ns.setVariable("args", new String[]{"param1", "param2"}, false);
i.source("Target.bsh");

如果可以的话,申请表是什么?
Interpreter i = new Interpreter();
NameSpace ns = i.getNameSpace();
ns.setVariable("args", new String[]{"param1", "param2"}, false);
i.source("Target.bsh");