code: public static String getModuleName(URL jrtUrl) {
      if (!"jrt".equalsIgnoreCase(jrtUrl.getProtocol())) {
        return null;
      }
      try {
        // use URI class to also decode path and remove escapes:
        String mod = jrtUrl.toURI().getPath();
        if (mod != null && mod.length() >= 1) {
          mod = mod.substring(1);
          int p = mod.indexOf('/');
          if (p >= 0) {
            mod = mod.substring(0, p);
          }
          return mod.isEmpty() ? null : mod;
        }
        return null;
      } catch (URISyntaxException use) {
        return null;
      }
    }
docs: Returns the module name from a {@code jrt:/} URL; returns null if no module given or wrong URL type.