-2

I want to unrar a file which contains one level of files.

That's what I made so far:

Runtime.getRuntime().exec("C:\\Program Files\\WinRAR\\WinRAR.exe unrar -x " + inputZipFile + " " + outputFolderPath);

And it doesn't make anything.

a_z
  • 342
  • 1
  • 3
  • 14
  • 3
    Runtime.exec was replaced years ago by [ProcessBuilder](https://docs.oracle.com/javase/8/docs/api/java/lang/ProcessBuilder.html). Be sure to call the ProcessBuilder's [inheritIO](https://docs.oracle.com/javase/8/docs/api/java/lang/ProcessBuilder.html#inheritIO--) method so you'll see the unrar command's output. – VGR Jun 10 '15 at 12:56
  • could you give me please an example ? – a_z Jun 10 '15 at 13:01
  • Try `new ProcessBuilder("C:\\Program Files\\WinRAR\\WinRAR.exe", "unrar", "-x", inputZipFile, outputFolderPath).inheritIO().start();`. – VGR Jun 10 '15 at 19:14
  • it's not working either – a_z Jun 11 '15 at 07:39
  • What does "not working" mean? Is your computer catching fire? If an exception is occurring, please edit your question and add the exception's entire stack trace. And you should show the try/catch blocks surrounding your process launching code. – VGR Jun 11 '15 at 14:30

1 Answers1

5

You might give a try this library:

https://github.com/edmund-wagner/junrar

This is some example code from the author:

https://github.com/edmund-wagner/junrar/blob/master/testutil/src/main/java/com/github/junrar/testutil/ExtractArchive.java

Marinos An
  • 9,481
  • 6
  • 63
  • 96
  • is there anything which is not involved with git? or either give me a link for a jar not for git please. – a_z Jun 10 '15 at 15:09
  • 1
    Seems to be this: http://mvnrepository.com/artifact/com.github.junrar/junrar/0.7 Just click on the download (JAR) button – Marinos An Jun 11 '15 at 14:03