Tuesday, April 22, 2008

Viewing jar files with Windows XP's Native Compressed File Viewer

Since Windows XP allows you to create, view, and edit zip files without an external program such as Winzip, I thought it would be a simple matter to view Java archives (jars, wars, and ears) as well. Turns out it's not too difficult to do. There are several ways to go about it:
  • The most basic method: Rename the jar file with a .zip extension.
    • You might as well install Winzip (or one of the free compression tools out there).
  • A better method: Copy HKEY_CLASSES_ROOT/.zip to HKEY_CLASSES_ROOT/.jar
    • I prefer to avoid editing the registry if possible. This method might also have unwanted side effects since you're copying all of the properties of the zip file type to the jar file type
  • The best method: Recreate the JAR file type.
    1. In Windows Explorer, go to Tools..Folder Options... Then click on the File Types tab.
    2. Find the jar file type and copy and paste all of the settings under advanced for action "Open" into a text file.
    3. Delete the JAR file type and create a new JAR file type. Click on advanced and then find Compressed (zipped) Folder in the drop down.
    4. After the JAR file type is created, click advanced and create a new action named "Run" (or whatever).
    5. Copy the settings that you saved before into the Run action. In case you lost the settings, here are mine:
      • Application used to perform action: "C:\Program Files\Java\jre1.6.0_05\bin\javaw.exe" -jar "%1" %*
      • Application: javaw
      • Topic: System
    6. You can now view and edit JAR files within Windows Explorer, and with a right-click, you can still run the JAR files from Windows Explorer as well!

No comments: