title: load resource from Jar file at runtime
body: <p>I am trying to load a resource from a Jar file added in at runtime and not getting very far.</p>
  
  <p>Here is my code (groovy):</p>
  
  <pre><code>URL url = new URL("jar:file:/out/resource.jar!/test.resource")
  def urlList = [] &lt;&lt; url
  URL[] urls = urlList.toArray()
  URLClassLoader classLoader = new URLClassLoader(urls, this.class.getClassLoader())
  InputStream stream = url.openStream()
  </code></pre>
  
  <p>I get this error: 
  java.util.zip.ZipException: error in opening zip file
      at java.util.zip.ZipFile.open(Native Method)</p>
  
  <p>Questions:  </p>
  
  <p>1) do I need to put "test.resource" in my url?
  2) What is the relationship between my URLClassLoader and my current class's classloader?
  3) what is the proper way to stream in this resource (obviously what I have doesn't work)?</p>
  
  <p>Thanks</p>