I want to use ProgressBuilder to run another jar with arguments inserted.
Example: es.jar file with Main class, and an arg sl.
I know I can use Runtime.getRuntime().exec() like this:
String arg = "sl";
Process p = Runtime.getRuntime().exec("java -cp \"es.jar " + arg + "\" Main");
If I use ProgressBuilder, without the arg sl, it would be like this:
processBuilder.command("java","-cp","es.jar", "Main").start();
However, arg sl is needed, how can I insert it? I have tried the following codes but obviously none of them work:
processBuilder.command("java","-cp","es.jar sl", "Main").start(); // failed
processBuilder.command("java","-cp","\"es.jar sl\"", "Main").start(); // failed also
slclass to run main function, which do not exist.processBuilder.command("java","-cp","es.jar", "Main", arg).start();- But I'm left thinking, can you send parameters to a class this way...