javajava-9java-module

How to get list of all modules programmatically in Java 9?


How can I get list of all modules in current JVM instance via Java code? Is it possible? If yes, then how?


Solution

  • ModuleLayer.boot().modules().stream()
                    .map(Module::getName)
                    .forEach(System.out::println);