I using Processbuilder as follows:
List<String> args = initArgs();
ProcessBuilder pb = new ProcessBuilder(args);
tdmServerProcess = pb.start();
handleInfoLog(tdmServerProcess.getInputStream());
handleErrorLog(tdmServerProcess.getErrorStream());
In the initArgs method I am setting the linux commands I want to execute, as follows:
args.add("java -version");
args.add(javaHome + File.separator + "bin" + File.separator + "java");
first command is getting executed successfully. But second is failing with following error:
/opt/java7/bin/java: cannot execute binary file
though i have execute permission, following are permission bits:
-r-xr-xr-x
I am able to execute the same command from terminal.