Issue:- If the executable command contain's any spaces then System.exec is omitting the string content after the first space.
For example:- if command="/opt/GUIInstaller/installers/abc def gh.bin" Then java is executing command up-to /opt/GUIInstaller/installers/abc only and resulting a error like java.io.IOException: "/opt/GUIInstaller/installers/abc": error=2, No such file or directory
protected void launch(final String command)
{
try
{
if(command.contains("null"))
{
logger.error("Installer is not located in the specified folder: "+command);
System.exit(0);
}
runTime.exec(command);
}
catch (IOException ioException) {
logger.error(ioException.getMessage(), ioException);
}
}
Is I am doing any mistake, please help me to solve this issue.
Environment:- Java7 update9 + RHEL6
"/opt/GUIInstaller/installers/abc\\ def\\ gh.bin"to escape the spaces