How to Extract a JAR File

Three Methods:WindowsMacLinux

A JAR file is a Java Archive file—a compressed file archive. It is equivalent to Zip files. When you extract a Jar file, you are extracting (or opening, unzipping, decompiling, etc.) the files from the Java Archive file into a directory. Once in the directory, you may access the individual files stored in the Jar Archive file.[1] Jar files open easily in Windows, but they are not naturally compatible with Mac and Linux operating systems. As a result, each operating system requires a slightly different extraction process.

Method 1
Windows

  1. Image titled Extract a JAR File Step 1
    1
    Open “This PC”, "Computer", or “My Computer”. In Windows 10 “My Computer” became “This PC”.
    • Windows 10: First, click on the File Explorer icon. This icon (Manila file in a blue file holder) is located in the bottom taskbar. Then, select "This PC" from the window's left sidebar.[2]
    • Windows 8: Right-click on a blank area of the canvas. Select "All Apps" from the bottom menu bar. Navigate to the section labeled "Windows System". Double-click on "Computer".[3]
    • Windows 7: Launch the Start menu and select "My Computer".[4]
  2. Image titled Extract a JAR File Step 2
    2
    Identify the drive your Jar file is in. The "This PC" window will list all of your computer's drives. The Jar file is store in one of these drives. Note the capital letter to the right of the drive's name. You will enter this into the command prompt later.[5]
  3. Image titled Extract a JAR File Step 3
    3
    Navigate to the Jar file you would like to extract.
  4. Image titled Extract a JAR File Step 4
    4
    Click on the file once to select it.
  5. Image titled Extract a JAR File Step 5
    5
    Click on the search bar at the top of the window. This will reveal the file’s path. It will list every drive and folder you opened to reach the file. It will not list the file’s name.
  6. Image titled Extract a JAR File Step 6
    6
    Copy the file’s path.
  7. Image titled Extract a JAR File Step 7
    7
    Open “Command Prompt”.
    • On your keyboard, press the Windows key + R. This will launch a program called "Run". Type "cmd" and press Enter. The Command Prompt program will open.[6]
  8. Image titled Extract a JAR File Step 8
    8
    Type the letter of the drive in the command line. Remember, this letter was located to the right of drive's name.[7]
    • For example, if the file is stored in “Local Disk (C):”, type “c”.
  9. Image titled Extract a JAR File Step 9
    9
    Type “d” immediately after. “d” stands for directory. Do not put a space between the drive and “d”.
    • For example: “cd”.
  10. Image titled Extract a JAR File Step 10
    10
    Hit the spacebar once and paste the file’s path.
    • For example: “cd C:\Program Files\Java\jdk1.7.0_79\bin”.
  11. Image titled Extract a JAR File Step 11
    11
    Press Enter.
  12. Image titled Extract a JAR File Step 12
    12
    Type “jar xf” in the command line. This is the jar file extraction command.
    • “x” is short for “extract”.
    • “f” is short for “file”.
    • Together, “xf” means you want to extract the file specified in the command line.
  13. Image titled Extract a JAR File Step 13
    13
    Hit the spacebar once and then type the name of the Jar file.
    • For example: “xf myjarfile.jar”.
  14. Image titled Extract a JAR File Step 14
    14
    Press Enter to extract the entire Jar file. This will decompile all of the files stored in the Jar file. These files will appear in the same location as the Jar file.
  15. Image titled Extract a JAR File Step 15
    15
    Extract specific files from the Jar file. If you know the exact file or files you want from the Jar file, there is no need to decompile the entire file. Instead, you can retrieve only the files you want.
    • After you’ve typed “xf myjarfile.jar”, press the spacebar once.
    • Enter the name of the file you want to extract. The name must be exactly as it appears in the Jar file.
    • If you would like to extract more than one file, press the spacebar and type the file’s name.
    • Repeat this process until you’ve listed all of the files you want to extract.
  16. Image titled Extract a JAR File Step 16
    16
    Press Enter. This will extract all of the files you listed. These files will appear in the same location as the Jar file.[8]

Method 2
Mac

  1. Image titled Extract a JAR File Step 17
    1
    Click on the Jar file once to select the file.[9]
  2. Image titled Extract a JAR File Step 18
    2
    Click on the file’s name once. This will allow you to edit the file’s name and type.
  3. Image titled Extract a JAR File Step 19
    3
    Delete “.jar” from the end of the file’s name. Without the right software, Macs can not extract files from a Jar file.
    • For the purpose of this example, the Jar file is named “myjarfile.jar”. After deleting the “.jar” from the end, you will be left with “myjarfile”.
  4. Image titled Extract a JAR File Step 20
    4
    Add “.zip” to the end of the file name. Macs can, however, decompile, or unzip, zip files. Changing the file type allows you to bypass downloading a Jar Extractor.
    • For example: “myjarfile.zip”.
  5. Image titled Extract a JAR File Step 21
    5
    Press Enter. A window will pop up with the following message: “Are you sure you want to change the extension from “.jar” to “.zip”?”
  6. Image titled Extract a JAR File Step 22
    6
    Click Use .zip. Your Jar file is now a zip file. All of the files compiled in the original Jar file will appear in a folder with the same name.[10]

Method 3
Linux

  1. Image titled Extract a JAR File Step 23
    1
    Drag the Jar file onto your desktop.[11]
  2. Image titled Extract a JAR File Step 24
    2
    Right-click on the file. A pop-up menu will appear.
  3. Image titled Extract a JAR File Step 25
    3
    Select “Rename”.
  4. Image titled Extract a JAR File Step 26
    4
    Select the file’s entire name.
  5. Image titled Extract a JAR File Step 27
    5
    Right-click on the highlighted name. A pop-up menu will appear.
  6. Image titled Extract a JAR File Step 28
    6
    Select “Copy”. You will eventually paste the file’s name in Terminal.
  7. Image titled Extract a JAR File Step 29
    7
    Press Cancel to exit out of the “Rename” window.
  8. Image titled Extract a JAR File Step 30
    8
    Right-click on the desktop. A pop-up menu will appear.
  9. Image titled Extract a JAR File Step 31
    9
    Select “Open Terminal Here”. Terminal will open at the desktop.
  10. Image titled Extract a JAR File Step 32
    10
    Type “java” in the command line.
  11. Image titled Extract a JAR File Step 33
    11
    Press the spacebar once.
  12. Image titled Extract a JAR File Step 34
    12
    Type “-jar”. “-” is a hyphen.
  13. Image titled Extract a JAR File Step 35
    13
    Press the spacebar once.
  14. Image titled Extract a JAR File Step 36
    14
    Select “Edit” from Terminal’s top menu bar.
  15. Image titled Extract a JAR File Step 37
    15
    Choose “Paste”.
  16. Image titled Extract a JAR File Step 38
    16
    Press Enter. You now have access to the contents of the Jar file.[12]

Article Info

Categories: File Manipulation | Java