This command runs from the command line successfully :
// /home/[user]/testproject/target/dependency/testproj-1.0-SNAPSHOT.jar
~/testproject/target/dependency$ jar -xf *.jar
But when I try to run the same command via ProcessBuilder I get :
java.io.FileNotFoundException: *.jar (No such file or directory)
ProcessBuilder code:
ProcessBuilder builder = new ProcessBuilder("jar", "-xf", "*.jar");
builder.directory("/home/[user]/testproject/target/dependency");
Process process = builder.start();
int exitValue = process.waitFor();
How can I make it work with the "*" among the command parameters?
From the command line the shell is performing globbing, converting *.jar to a list of actual files all ending with .jar.
When run via ProcessBuilder no shell is involved. You must either:
/bin/bash or whatever shell you use and the jar command would be the first argument to the shell.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With