java-9java-modulejava-platform-module-systemjdepsjdeprscan

How can I get the list of all possible packages from lib/ directory using jigsaw helper commands?


I'm not currently building a modular app.

However I've seen that that jdeps/jdeprscan can scan into jars for packages.

Is there a way to just print all packages contained in all jars inside lib/ using any of the above commands?


Solution

  • One solution I have found is this:

    # jdk8
    /jdk8/bin/jdeps -classpath lib/* | grep '^\s*\->' | awk '{print $2}' | sort | uniq
    
    # >=jdk9
    /jdk9/bin/jdeps -classpath lib/* | grep '^\s' | awk '{print $1}' | sort | uniq | grep -v '<unnamed>'
    
    

    It prints the list of all packages contained in all jars of lib/ dir.