Blog Archive

5 Sept 2008

NetRexx script to extract version information from .ear


/*
* NetRexx program to extract information from Java CAPS
* enterprise archive files.
* Only .ears generated from CAPS versions >= 5.1.3 have
* this information.
*
*/

import java.util.jar.

method main(args=String[]) static
if args.length > 0 then do
loop i=0 to args.length - 1
jf = JarFile(args[i])
attr = jf.getManifest.getAttributes('Application Information')

say args[i]': \-'

do
buildtime = attr.getValue('CAPS-Build-Time')
catch NullPointerException
buildtime = '(not found)'
finally
say buildtime '\-'
end

do
dpname = attr.getValue('CAPS-Deployment-Profile-Name')
catch NullPointerException
dpname = '(not found)'
finally
say ' | ' dpname '\-'
end

say
end
end