I am struggling with a whitespace error in the exec Runtime Java method. Here's what's unique about this problem: the command I'm trying to execute is an input string and may or may not have spaces and not necessarily in any particular format. In any case, I need to execute it. If there are no spaces, I am good; if there are gaps, I'm not so good.
How can I explain both circumstances?
Bonus info at no extra charge: one of the big problems seems to be that I am trying to call the executable in c: \ program files \ blablabla ... and exec seems to break into a space after the 'c: \ program. I am sure that other parameters will also appear in the parameters.
Here is a more specific example of the types of strings I can get. This should fix some confusion:
- C: \ someApp \ someapp.exe
- c: \ someApp \ someapp.exe -someParam = foo
- c: \ program files \ someapp \ someapp.exe
- c: \ program files \ someapp \ someapp.exe -someParam = bar
The first one works great because it has no spaces. The second one is even normal, because it splits into space and uses the first as a command, and the second as a parameter. The third and fourth examples are divided into the first space, use "C: \ program" and the command "files ..." and (in the case of the fourth line) "-someParam = bar" as parameters.
source
share