Reputation: 31
I'm trying to write a batch file (run.bat
) that can be invoked something like this:
run.bat "whatever.log"
But under the hood, the batch file is passing the argument ("whatever.log"
) to the following command:
java -cp "fizz.jar;a.jar;b.jar;c.jar;d.jar" com.myapp.FizzDriver "whatever.log"
Again, if you run: run.bat "blah.txt"
, then that batch file would execute:
java -cp "fizz.jar;a.jar;b.jar;c.jar;d.jar" com.myapp.FizzDriver "blah.txt"
My best attempt at run.bat
so far is:
@ECHO OFF
%JAVA_HOME%\bin\java java -cp "fizz.jar;a.jar;b.jar;c.jar;d.jar" com.myapp.FizzDriver ???
But I'm not sure how to parameterize the argument (???). I'm also not sure if the batch file is missing anything or is incorrect with the way I've written it. Ideas? Thanks in advance!
Upvotes: 0
Views: 3448
Reputation: 2691
To pass one command line parameter, use %1
. If you need to pass more than one, you can either use %1 %2
etc, or use %*
to pass all of them at once.
Upvotes: 2
Reputation: 310913
You just need to put %1, but you have another issue. When you use 'java -jar', the '-cp' argument is ignored: the CLASSPATH is taken from the jar manifest only.
Upvotes: 2