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.
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
- 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.
- 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".
- Windows 7: Launch the Start menu and select "My Computer".
- 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.
- Navigate to the Jar file you would like to extract.
- Click on the file once to select it.
- 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.
- Copy the file’s path.
- 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.
- Type the letter of the drive in the command line. Remember, this letter was located to the right of drive's name.
- For example, if the file is stored in “Local Disk (C):”, type “c”.
- Type “d” immediately after. “d” stands for directory. Do not put a space between the drive and “d”.
- For example: “cd”.
- Hit the spacebar once and paste the file’s path.
- For example: “cd C:\Program Files\Java\jdk1.7.0_79\bin”.
- Press Enter.
- 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.
- Hit the spacebar once and then type the name of the Jar file.
- For example: “xf myjarfile.jar”.
- 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.
- 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.
- Press Enter. This will extract all of the files you listed. These files will appear in the same location as the Jar file.
Mac
- Click on the Jar file once to select the file.
- Click on the file’s name once. This will allow you to edit the file’s name and type.
- 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”.
- 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”.
- Press Enter. A window will pop up with the following message: “Are you sure you want to change the extension from “.jar” to “.zip”?”
- 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.
Linux
- Drag the Jar file onto your desktop.
- Right-click on the file. A pop-up menu will appear.
- Select “Rename”.
- Select the file’s entire name.
- Right-click on the highlighted name. A pop-up menu will appear.
- Select “Copy”. You will eventually paste the file’s name in Terminal.
- Press Cancel to exit out of the “Rename” window.
- Right-click on the desktop. A pop-up menu will appear.
- Select “Open Terminal Here”. Terminal will open at the desktop.
- Type “java” in the command line.
- Press the spacebar once.
- Type “-jar”. “-” is a hyphen.
- Press the spacebar once.
- Select “Edit” from Terminal’s top menu bar.
- Choose “Paste”.
- Press Enter. You now have access to the contents of the Jar file.
Sources and Citations
- ↑ https://docs.oracle.com/javase/tutorial/deployment/jar/unpack.html
- https://support.microsoft.com/en-us/instantanswers/5bbfca73-ff4c-49e2-89de-b123f9ae4eb6/my-computer-is-now-this-pc
- https://www.youtube.com/watch?v=dIPVrJHGgmQ
- http://www.computerhope.com/jargon/m/mycomput.htm
- ↑ http://www.computerhope.com/jargon/d/drive.htm
- http://www.digitalcitizen.life/7-ways-launch-command-prompt-windows-7-windows-8
- ↑ https://www.youtube.com/watch?v=lV3npU1NbHQ
- ↑ https://www.youtube.com/watch?v=DVD9DIxs9Lo