IllegalArgumentException : Executable name has embedded quote, split the arguments

只谈情不闲聊 提交于 2019-12-23 07:09:09

问题


I'm getting an error :

IllegalArgumentException : Executable name has embedded quote, 
split the arguments 

While running the

Runtime.getRuntime().exec(cmd, envTokens, file1);

I'm using Windows7 and Java7 machine .

Same line of code is working fine for other environments .

Suggest me some way .


回答1:


This happens because of a change in Java 7 update 21/Java 6 update 45.

The solution to your problem is to refactor your code to use java.lang.ProcessBuilder instead. For instance:

ProcessBuilder pb = new ProcessBuilder("command", "argument1", "argument2");
Map<String, String> env = pb.environment();
env.put("var1", "value1");
Process p = pb.start();


来源:https://stackoverflow.com/questions/16890457/illegalargumentexception-executable-name-has-embedded-quote-split-the-argumen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!