[英]java program arguments from bat file
I've got a Java program that takes parameters such as "-range=1-5 -message=Hello". 我有一个Java程序,该程序带有诸如“ -range = 1-5 -message = Hello”之类的参数。
I've a written a .bat file to launch that java program with a specific jre and some preset parameters. 我已经编写了一个.bat文件以使用特定的jre和一些预设参数启动该Java程序。 I would like to be able to launch the .bat file with some extra parameters to be added to the java program.
我希望能够启动带有一些额外参数的.bat文件,以将其添加到Java程序中。
the myexe.bat file is myexe.bat文件是
echo on
rem Force 32 bit Java
"C:\Program Files (x86)\Java\jdk1.8.0_162\bin\java.exe" -jar myexe.jar -param1="value1" %1 %2 %3 %4 %5 %6 %7 %8 %9
I'm expecting that calling 我希望那个电话
myexe.bat -param2=value2
would lead to 会导致
.. -jar myexe.jar -param1="value1" -param2=value2
Instead it's leading to 相反,它导致
.. -jar myexe.jar -param1="value1" -param2 value2
Which is wrongly interpreted by the java program. java程序错误地解释了这一点。
Surrounding by quotes such as in .. -jar myexe.jar -param1="value1" "-param2=value2"
用引号引起来,例如
.. -jar myexe.jar -param1="value1" "-param2=value2"
Instead it's leading to 相反,它导致
.. -jar myexe.jar -param1="value1" "-param2=value2"
Which is also wrongly interpreted by the java program. java程序也错误地解释了这一点。
Is there a way in the .bat file to use its arguments exactly as they were set ? .bat文件中是否有一种方法可以完全按照其设置使用其参数?
%*
is usually the simplest solution here. %*
通常是这里最简单的解决方案。 Eg this batch file: 例如,此批处理文件:
echo %1 %2 %3
echo %*
Produces this output: 产生以下输出:
>mybat.bat -param2=value2
>echo -param2 value2
-param2 value2
>echo -param2=value2
-param2=value2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.