Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try this (I've grabbed it somewhere on the Internet): </p> <pre><code>import java.io.File; import java.io.IOException; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public final class ClassPathHacker { private static final Class&lt;?&gt;[] PARAMS = new Class&lt;?&gt;[] { URL.class }; private static final Logger LOG_CPH = LoggerFactory.getLogger(ClassPathHacker.class); private ClassPathHacker() {} public static void addFile(final String pFileName) throws IOException { final File myFile = new File(pFileName); ClassPathHacker.addFile(myFile); } public static void addFile(final File pFile) throws IOException { ClassPathHacker.addURL(pFile.toURI().toURL()); } public static void addURL(final URL pFileUrl) throws IOException { /* variables definition */ final URLClassLoader sysLoader = (URLClassLoader) ClassLoader.getSystemClassLoader(); final Class&lt;?&gt; sysClass = URLClassLoader.class; try { final Method myMethod = sysClass.getDeclaredMethod("addURL", PARAMS); myMethod.setAccessible(true); myMethod.invoke(sysLoader, new Object[] { pFileUrl }); } catch (final Exception exc) { ClassPathHacker.LOG_CPH.error(exc.getLocalizedMessage(), exc); throw new IOException(exc.getLocalizedMessage()); } } } </code></pre> <p>Together with this method:</p> <pre><code>private static void hackClassPath(final File myData) { if (myData.isDirectory()) { /* block variables */ final File[] myList = myData.listFiles(); /* hacking classpath... */ for (final File tmp : myList) { try { ClassPathHacker.addFile(tmp.getAbsolutePath()); MainApplication.MAIN_LOG.trace("{} added to classpath", tmp.getAbsolutePath()); } catch (final IOException iOE) { MainApplication.MAIN_LOG.error(iOE.getLocalizedMessage(), iOE); } } } } </code></pre> <p>And with this sample call:</p> <pre><code> MainApplication.hackClassPath(new File("test/data")); MainApplication.hackClassPath(new File("data")); </code></pre> <p>A bit hacky, but maybe it works... it runtime adds all JAr files available in the data or test/data directory to the running classpath.</p>
    singulars
    1. This table or related slice is empty.
    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. This table or related slice is empty.
    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