4

My java program works fine with cmd. It takes 5arguments and also has external library. So I am running it from cmd like

java -cp .;jxl.jar MyProgram d: abc 1 d://sv 0

I would like to develop .cmd file which will run this program and also all these arguments should be passed to that cmd file and this cmd file will give it to the jar.

So what I want is

runner.cmd d: abc 1 d://sv 0

and all these argument should get passed to java runner command.

Till now what I have done is that, I have created a cmd file with

@echo off

java -cp ,;jxl.jar MyProgram d: abc 1 d://sv 0

It works fine. Now I dont know how to pass parameters from cmd to jar.

Mr x
  • 828
  • 1
  • 8
  • 25

2 Answers2

3

Write your runner.cmd as

@echo off
java -cp .;jxl.jar MyProgram %*

%* is a wildcard for all parameters passed to the batch file.

wero
  • 32,544
  • 3
  • 59
  • 84
1

You can reference them using %1, %2 and so on. Put this in your file:

java -cp ,;jxl.jar MyProgram %1 %2 %3 %4 %5

Then you can call it using

runner.cmd d: abc 1 d://sv 0
f1sh
  • 11,489
  • 3
  • 25
  • 51