Execute external command in Java with syntax

0
Hello, I'm using a DOS file to unzip .zip files, it's UNZIP.EXE (DOS executable) itself. I am mounting the code as follows:

Desktop.getDesktop().open(new File("e:\unzip.exe teste.zip" ));

It does not work at all, it gives an error saying that the ZIP file was not found, I already tested it that way, and it did not work either:

ProcessBuilder p = new ProcessBuilder();
p.command("e:\unzip.exe", "e:\teste.zip");
p.start(); 

It did not work either, what am I doing wrong? I basically need to run the unzip.exe command with the ZIP file name in sequence, just that.

Thanks for any help! Thanks!

    
asked by anonymous 15.06.2015 / 03:03

1 answer

0

I took a look at doc and you would have to pass a list of String with the parameters and not in this way you did, try:

ProcessBuilder p = new ProcessBuilder(new String[]{"e:\unzip.exe", "e:\teste.zip"});
p.start();
    
15.06.2015 / 03:21