I have written a java program to unzip a jar file.
My code looks like this:
import java.io.File;
import java.io.IOException;
public class MainClass {
public static void main(String[] args) {
Runtime r = Runtime.getRuntime();
Process p = null;
try {
File dir = new File("C:/Program Files/WinRAR");
p = r.exec("winrar x h:\\myjar.jar *.* h:\\new", null, dir);
} catch (IOException e) {
e.printStackTrace();
}
}
}
When I run this, I am getting this error:
java.io.IOException: Cannot run program "winrar" (in directory "C:\Program Files\WinRAR"): CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at MainClass.main(MainClass.java:16)
Caused by: java.io.IOException: CreateProcess error=2, The system cannot find the file specified
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 4 more
Can someone tell me why this error occurred? and please guide me to fix this issue.