Redirecting passed arguments to a windows batch file

WindowsBatch FileArguments

Windows Problem Overview


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,

Required Command line:

foo.bat --flag1=x --flag2=y --flag3=z

The batch file foo.bat should invoke foo.jar like follows:

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?

Windows Solutions


Solution 1 - Windows

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKrishna GopalakrishnanView Question on Stackoverflow
Solution 1 - WindowstschaibleView Answer on Stackoverflow