Sotirios Delimanolis
Sotirios Delimanolis

Reputation: 279890

Running Java program from Batch script with correct number of arguments

I have a java program can take a variable amount of parameters. Something like:

package other;
public class Main {
    public static void main (String[] args) {
        for (String arg: args) {/* do something */}
    }
}

I want to run this java program from a .bat script.

"%JAVA_HOME%\bin\java" -cp "/some.jar;other.jar" other.Main %1 %2 %3

With this I can call my .bat script like

> myscript.bat arg1 arg2 arg3

This works if I have 3 arguments, but there can be a variable amount of arguments passed. How can I pass them all to the java program?

Upvotes: 1

Views: 4728

Answers (1)

Andrii Tykhonov
Andrii Tykhonov

Reputation: 538

%* holds all arguments passed to a script.

Upvotes: 2

Related Questions