Java ProcessBuilder calling another java with arguments -


i want use progressbuilder run jar arguments inserted.

example: es.jar file main class, , arg sl. know can use runtime.getruntime().exec() this:

string arg = "sl"; process p = runtime.getruntime().exec("java -cp \"es.jar " + arg + "\" main"); 

if use progressbuilder, without arg sl, this:

processbuilder.command("java","-cp","es.jar", "main").start(); 

however, arg sl needed, how can insert it? have tried following codes none of them work:

processbuilder.command("java","-cp","es.jar sl", "main").start(); // failed processbuilder.command("java","-cp","\"es.jar sl\"", "main").start(); // failed 

java -cp "es.jar sl" main makes no sense, , i'm pretty sure otherwise fail

java states java [-options] class [args...], first parameter after options class executed, based on question, mean needs be

java -cp es.jar main sl, or in more specifically, in regards question, processbuilder.command("java","-cp","es.jar", "main", arg).start();


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -