0

I'm looking for a Windows script/batch file that will search a specified directory and subdirs (or possibly use the CLASSPATH?) for jar files, then search in those jars for a specified class.

It'd be best if it didn't need another package to run, but if you need to use cygwin, that's acceptable.

I've had to do this by hand before (exploding the jars, etc.), and it's not very fun.

billjamesdev
  • 103
  • 4
  • Did you check http://stackoverflow.com/questions/346811/listing-the-files-in-a-directory-of-the-current-jar-file? – nik Jun 15 '09 at 17:01

3 Answers3

1

Jar Browser does this nicely, and has the added benefit of being written in Java, so you can use it anywhere.

cgp
  • 1,032
  • 3
  • 12
  • 15
0

JAR files use the ZIP format. That should make it a lot easier to automate, if you didn't already know it.

sangretu
  • 372
  • 1
  • 2
  • 8
0

You can browse through jar/zip files in powershell using DotNetZip.

$SourceFile = "c:\files\filename.jar" 
[System.Reflection.Assembly]::LoadFrom("c:\Files\Ionic.Zip.dll") 
$zipfile = [Ionic.Zip.ZipFile]::Read($sourceFile) 
foreach($file in $zipfile) 
    {$file.FileName} 
$zipfile.Dispose() 

All you would have to do is iterate through the classpath or whatever set of JARs you want to search for.

DotNetZip is free.

Cheeso
  • 572
  • 3
  • 18