I am running these line of codes to run a Test.jar which is an executable jar
public static void main(String[] args) throws IOException{
File f = new File("path to exe jar");
if(f.exists() && !f.isDirectory()) {
System.out.println("Valid");
}else{
System.out.println("Invalid");
}
ProcessBuilder pb =
new ProcessBuilder("path to exec jar", "-jar", "Test.jar",
"args1","args2","args3","args4");
pb.directory(new File("path to exec jar"));
Process p = pb.start();
}
And I keep getting this error: File is valid though so I think this might be access issues. What do I need to add to get the access needed?
Valid
Exception in thread "main" java.io.IOException: Cannot run program "abc" (in directory "abc"): CreateProcess error=5, Access is denied
"path to exe jar"
should be "java"
in the constructor for ProcessBuilder
. You can't execute a path.