Q:

How to pass getopts argurements to a shell script using java

I want to run a shell script using java using Runtime.getRuntime().exec(). However, my shell script is using getopts so I need to use this command in terminal to run the script:
./script.sh -l 01 -n 02 

So how can i execute this script with multiple args using java? I tried the bellow code but I does not work.
String[] args = {"script.sh", "-l 01", "-n 02"};
Runtime.getRuntime().exec(args);

A:

Each argument is a separate String. Like,
String[] args = { "script.sh", "-l", "01", "-n", "02" };

