Extract a JAR File

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.

Steps

Windows

  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. 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. Navigate to the Jar file you would like to extract.
  4. Click on the file once to select it.
  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. Copy the file’s path.
  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. Type the letter of the drive in the command line. Remember, this letter was located to the right of drive's name.[5]
    • For example, if the file is stored in “Local Disk (C):”, type “c”.
  9. Type “d” immediately after. “d” stands for directory. Do not put a space between the drive and “d”.
    • For example: “cd”.
  10. Hit the spacebar once and paste the file’s path.
    • For example: “cd C:\Program Files\Java\jdk1.7.0_79\bin”.
  11. Press Enter.
  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. Hit the spacebar once and then type the name of the Jar file.
    • For example: “xf myjarfile.jar”.
  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. 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. Press Enter. This will extract all of the files you listed. These files will appear in the same location as the Jar file.[1]

Mac

  1. Click on the Jar file once to select the file.[7]
  2. Click on the file’s name once. This will allow you to edit the file’s name and type.
  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. 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. 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. 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.[7]

Linux

  1. Drag the Jar file onto your desktop.[8]
  2. Right-click on the file. A pop-up menu will appear.
  3. Select “Rename”.
  4. Select the file’s entire name.
  5. Right-click on the highlighted name. A pop-up menu will appear.
  6. Select “Copy”. You will eventually paste the file’s name in Terminal.
  7. Press Cancel to exit out of the “Rename” window.
  8. Right-click on the desktop. A pop-up menu will appear.
  9. Select “Open Terminal Here”. Terminal will open at the desktop.
  10. Type “java” in the command line.
  11. Press the spacebar once.
  12. Type “-jar”. “-” is a hyphen.
  13. Press the spacebar once.
  14. Select “Edit” from Terminal’s top menu bar.
  15. Choose “Paste”.
  16. Press Enter. You now have access to the contents of the Jar file.[8]

Sources and Citations