How can I run a batch file and pass parameters to jar file?
this doesn’t work
mybat.bat
java -jar log_parser.jar %1 %2 %3 %4
running bat file
C:\>log_parser.bat -file=C:\\trace_small.log -str=Storing
java sees only -file
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I just tried with a small java program that only dumps the arguments to the screen:
and the following batch file :
and I ended up with the following result
For the same command line as you… the equal sign ‘=’ desapeared.
Now if you trun the batch file to this :
you will get yet another result (which might be what you expected – not clear)
The advantage on this %* syntax, is that it is more extensible by accepting any number of arguments.
Hope this helps, but I recommend you to have a look at your code to and add some debug statement to understand where you are “lossing” some part of the input.