将传递的参数重定向到 Windows 批处理文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/980331/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Redirecting passed arguments to a windows batch file
提问by Krishna Gopalakrishnan
I would like to call a jar file from a windows batch file. One requirement is to be able to pass all the batch file arguments as-is to the jar file invocation. For example,
我想从 Windows 批处理文件中调用 jar 文件。一项要求是能够将所有批处理文件参数按原样传递给 jar 文件调用。例如,
Required Command line:
所需的命令行:
foo.bat --flag1=x --flag2=y --flag3=z
The batch file foo.bat
should invoke foo.jar
like follows:
批处理文件foo.bat
应foo.jar
如下调用:
java -jar foo.jar --flag1=x --flag2=y --flag3=z
How do I make the batch file do this?
I can do some batch variable magic with % to do this, but is there a simpler way to do this?
如何使批处理文件执行此操作?
我可以用 % 做一些批处理变量魔术来做到这一点,但有没有更简单的方法来做到这一点?
回答by tschaible
Does
做
java -jar foo.jar %*
meet your needs? It should add all parameters from the batch execution to your application call within the batch file.
满足您的需求?它应该将批处理执行中的所有参数添加到批处理文件中的应用程序调用中。