1

I'm trying to decompress a rar file, using the runtime but it doesn't works!, just open a prompt saying that can't find the file this is the code for it:

try {
      Runtime.getRuntime().exec("C:\\Program Files (x86)\\WinRAR\\WinRAR.exe X *ok*.rar F:\\");        
  } catch (IOException ex) {
      System.out.println(ex);        
  }

also i've used the processbuilder and that's worse, dosen't do anything ¬_¬

ProcessBuilder b = new ProcessBuilder("C:\\\\Program Files (x86)\\\\WinRAR\\\\WinRAR.exe X *sok*.rar F:\\");

here is where i find the information about the winrar

Carlos Carrizales
  • 2,340
  • 3
  • 18
  • 24
  • You might want to take a look here: http://stackoverflow.com/questions/9324933/what-is-a-good-java-library-to-zip-unzip-files – Kelo Apr 20 '15 at 15:13
  • @Kelo thanks for the advice, the main answer there (for me) suggest to do the process in phyton, but i don't want to change my code, not right now, may be later, and the other answers are for zip files, i use it but only works with zips not rars, thanks anyway – Carlos Carrizales Apr 20 '15 at 15:20
  • Java [Runtime](http://docs.oracle.com/javase/8/docs/api/java/lang/Runtime.html) documentation lists several methods how to run an application. In your case it is best to use the method with `String[] cmdarray`, i.e. an array of strings. First string is `WinRAR.exe` with full path containing spaces and must be therefore quoted which is the reason why your single string solution does not work (missing "..." for command processor). The second argument / string is `"x"`, the third one is `"*ok*.rar"` and the last one is `"F:\\"`. – Mofi Sep 02 '15 at 06:04

1 Answers1

0

looks like path issue.( C:\Program Files (x86)\WinRAR\WinRAR.exe X ok.rar F:\")

"\" may be used along with roots eg(c:\, D:\) and then follows "\"

D:\programfiles\winar