Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9294197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T21:18:54+00:00 2026-06-18T21:18:54+00:00

I am trying to expand a zip file using 7zip but I keep getting

  • 0

I am trying to expand a zip file using 7zip but I keep getting the 7zip Usage printout.

The zip exist in c:\temp

The same command succeed in batch window :

C:\TEMP>7z x "tryThis.zip"

I tried adding the workdir path to the file,And also without the working dir,
nothing help. – I can probably run this using CMD/c command but I prefer to keep the code clean

What am I doing wrong?

Thank you!

String  pathTo7ZipExe = "c:\\program files\\7-zip\\7z.exe";
String fileName ="tryThis.zip";
String workingDir = "c:\\temp\\";

Process process = Runtime.getRuntime().exec(
                                     new String[]{pathTo7ZipExe},
                                     new String[]{" x \"" + fileName +"\""},
                                     new File(workingDir)); 

BufferedReader in = new BufferedReader(new InputStreamReader(process.getInputStream()));  
String line;  
while ((line = in.readLine()) != null) {  
      System.out.println(line);  
}  
// wait for zip to end.
int exitVal = process.waitFor();  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T21:18:56+00:00Added an answer on June 18, 2026 at 9:18 pm

    Please have a look at the documention for Runtime.exec

    What you were actually trying to do is calling 7-zip without arguments and providing the arguments as your environment. Environment is something like Windows PATH etc.

    so you would probably want to do something like:

    Runtime.getRuntime().exec(new String[]{pathToZipExe, "x", fileName}, null, new File(workingDir));
    

    On the other hand I would strongly advise to have a look on ZipInputStream which is included in java – using that you can also unpack zip files.

    Cheers

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small problem trying to unzip a file using the 7za command-line
I'm trying to run the expand shell command on all files found by a
I'm trying to expand a minified CSS file (don't ask) to make it human
I'm not a programmer, but I'm trying to expand an opensource Ajax contact form
I'm trying to expand my searchbar using jQuery. Also I want to hide the
I am trying to write a tool to create a zip file containing all
In Python, I wrote this: bvar=mht.get_value() temp=self.treemodel.insert(iter,0,(mht,False,*bvar)) I'm trying to expand bvar to the
I'm trying to expand a UITableViewCell to fill the entire screen using CoreAnimation. How
I am trying to Expand/Collapse a DIV . I am using a function to
I am trying to expand the relationships within my Django Models. I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.