Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Conceptually, what am I doing when I'm loading a new Jar?</p> </blockquote> <p>Conceptually, you are not loading a new JAR. Rather, you are defining a class loader which will load code and other resources from the JAR file on demand.</p> <blockquote> <p>Is URLClassloader the only choice? </p> </blockquote> <p>In theory, you could implement your own subclass of <code>ClassLoader</code>, but that's not necessary for what you are trying to do.</p> <blockquote> <p>How should I form those URLs to point to a subdirectory containing more jars.</p> </blockquote> <p>This is the nub of your problem I think. The <a href="http://java.sun.com/javase/6/docs/api/java/net/URLClassLoader.html" rel="nofollow noreferrer"><code>URLClassLoader</code></a> constructors interpret the <code>URL[]</code> argument as follows:</p> <blockquote> <p><em>"Any URL that ends with a '/' is assumed to refer to a directory. Otherwise, the URL is assumed to refer to a JAR file which will be downloaded and opened as needed."</em></p> </blockquote> <p>In the first case of the quoted text above, the directory is assumed to be the root of tree containing resources to be loaded. </p> <p>But I gather you are trying to set up a class loader that will load from all JAR files in a given directory. To do that, you need to:</p> <ol> <li>Read the directory and build a list of the <code>File</code> objects for any JAR files.</li> <li>Create an array to hold the same number of <code>URL</code> instances.</li> <li>For each JAR file <code>File</code>, use <code>File.toURL()</code> to create a <code>URL</code> and add to the array. (Using <code>File.toURL()</code> means that you will get kosher "file:" URLs for the JAR files that will work on your platform.)</li> <li>Create the <code>URLClassLoader</code> using the <code>URL</code> array.</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload