diff -r b862d16a2e9f -r abbc9bcfbcc4 relpipe-data/examples-runnable-jars.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/relpipe-data/examples-runnable-jars.xml Mon Feb 03 22:10:07 2020 +0100 @@ -0,0 +1,68 @@ + + + Finding runnable JARs + look for Java archives with a main class + 03900 + + + +

+ Java archives (*.jar files) that have set the main class can be started using java -jar program.jar command. + Let us find all JARs under a certain directory that are runnable. +

+ + + +

+ The script above will print output like this one: +

+ + + +

+ This pipeline consists of five steps: +

+ +
    +
  • + findFiles + – prepares the list of files separated by \0 byte; + if we omit the -iname '*.jar', the result will be the same, + just more files will be examinated +
  • +
  • + fetchAttributes + – does the heavy work – tries to open each given file as a JAR (same as ZIP format) + and looks for the Main-Class field in the META-INF/MANIFEST.MF file (if any); + because the jar_info streamlet itself is written in Java, it simply uses existing Java functionality for main class lookup instead of reimplementing it in custom code; + thanks to --parallel N option, utilizes N cores of our CPU; + we can experiment with the N value and look how the total time decreases +
  • +
  • + filterRunable + – uses AWK to skip the records (files) that does not have a main class; + in this step we could use also relpipe-tr-sql or relpipe-tr-guile if we prefer SQL or Guile/Scheme to AWK +
  • +
  • + shortenPath + – replaces part of the absolute path with the ~ shortcut + (just to make it shorter and hide our username) +
  • +
  • + relpipe-out-tabular + – formats the results as a table in the terminal (we could use e.g. relpipe-out-gui to call a GUI viewer or format the results as XML, CSV or other format) +
  • +
+ +

+ We can omit the -iname '*.jar' and run this pipeline on another directory + in order to find all valid JAR and ZIP files regardless their extension. + We will get also the number of entries (files and directories) in each archive. + In future versions, this streamlet might be extended to optionally provide files from the archive or their list e.g. in form of XML. +

+ +
+ +