I'm having some issues with ProcessBuilder.start();
.
Here's an example of what the code looks like:
List<String> listOfStrings = new ArrayList<String>();
myListOfString.add("zip");
myListOfString.add("-r");
myListOfString.add(destinationPath);
myListOfString.add(newFilePath);
File zipFile = new File(workingDirectory, fileName + ".zip");
ProcessBuilder processBuilder = new ProcessBuilder(listOfStrings);
prcoessBuilder.directory(workingDirectory);
try{
Process p = processBuilder.start();
...
...
...
workingDirectory
has been verified to be a working directory using workingDirectory.isDirectory()
.
The issue occurs at Process p = processBuilder.start();
where it throws an IOException.
Below is the stacktrace:
java.io.IOException: Cannot run program "zip" (in directory "<Path to workingDirectory>"): error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)
...
...
...
workingDirectory
does not point to a specific file (E.g.: /path/to/
, not /path/to/file.zip
), however, it is a valid directory. Is that possibly the issue?
I cannot give the exact code due to the nature of the project, but I can't imagine the input matters too much if it's crashing at Process p = processBuilder.start();
, however, this is why I'm reaching out so it might be the case.
Let me know if any clarification is needed.