With Windows XP, I recall being able to using Windows Search to find which jars in a dir contain a specific class file. But on Windows 7, this no longer seems to work. I've got the Search option checked to "Include compressed files (ZIP, CAB, ...)" but that doesn't seem to help. Searching File Contents (which appears as a choice after the initial search fails) also doesn't seem to work.

I was able to find the file by using the following command, but that's a pain (have to open a command prompt in the desired dir, paste the updated command, and visually inspect the results which can be very long if there are many jars).

for %i in (*.jar) DO %JDKHOME%\bin\jar.exe tf %i | grep myfile

By default, Windows 7 doesn't think .jar is a zip file that it can open, so doesn't enumerate its contents. You can fix this with the following registry addition:

Windows Registry Editor Version 5.00


Either paste that into a text file and save as fix.reg, then open it and agree to add it to the registry.

EDIT : The GUID is unique per machine. Instead:

Open registry editor, and Navigate to the key HKEY_CLASSES_ROOT\.zip\PersistentHandler and copy the value in (Default).

Then go to HKEY_CLASSES_ROOT\.jar, add a new key PersistentHandler, and paste the copied GUID into the (Default) value.

Then in explorer searching in jar files with work, using the search file contents option.

  • Interesting, I'll try that. How about .war and .ear? – Cincinnati Joe May 19 '11 at 22:02
  • Guess the same steps should hold good for wars & ears – Sathyajith Bhat May 20 '11 at 5:10
  • Should be the same, provided both are just standard zip files with different extensions – Spectre May 20 '11 at 14:00
  • 1
    This almost worked :) The GUID doesn't work on my Win7 machine. Neither does the GUID in the 2 yr-old StackOverflow question I then found:How to search Jar files using Windows Search? Another place online said to copy the entries from .zip, so I copied that GUID which worked for .jar, .war, .ear, .rar: [HKEY_CLASSES_ROOT\.jar\PersistentHandler] @="{098f2470-bae0-11cd-b579-08002b30bfeb}" – Cincinnati Joe May 24 '11 at 17:06
  • I see. I guess that GUID must be randomly generated per install, which I find a bit odd, but yes, copying the GUID from the .zip entry is the correct thing to do (and what I did when I created my answer). Ill update my answer. – Spectre May 24 '11 at 17:34

I always use Far Manager http://www.farmanager.com/ , it has a very flexible utility "find file" which can search also in archives.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.