code: public static Path getJarPathFromUrl(URL jarUrl) {
          try {
              String pathString = jarUrl.getPath();
              // for Jar URL, the path is in the form of: file:/path/to/groovy/myJar.jar!/path/to/resource/myResource.txt
              int endIndex = pathString.lastIndexOf("!");
              return Paths.get(new URI(pathString.substring(0, endIndex)));
          } catch (URISyntaxException e) {
              throw new IllegalStateException("Unsupported URL syntax: " + jarUrl.getPath(), e);
          }
      }
docs: Find the jar containing the given resource.
  
  @param jarUrl URL that came from a jar that needs to be parsed
  @return {@link Path} to the Jar containing the resource.