I am facing below error:
java.io.IOException: Cannot run program "C:\abc\man\b\manu.bat C:\Users\12x\test\testFiles\abc.properties" (in directory "C:\Users\12x\test\testFiles\abc.properties"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048).
Please find the code i am using:
public class TestProcess {
public TestProcess(Path workPath, Path exe, Path logbackConfig,
Path propertyfile) throws IOException {
String exeSuffix = "";
if (OS.indexOf("win") >= 0) {
exeSuffix = ".bat";
}
builder = new ProcessBuilder()
.directory(workPath.toFile())
.command(workPath.resolve(exe).toAbsolutePath().toString() + exeSuffix+ " " + propertyfile)
.redirectOutput(Redirect.INHERIT)
.redirectError(Redirect.INHERIT);
My aim is to run a bat file(which is present in C:\abc\man\b folder) followed by abc.properties(which is in another folder C:\Users\12x\test\testFiles).
In code above, workPath has the value
C:\abc\man\b
and propertyfile has
C:\Users\12x\test\testFiles