title: Java class is not found when loading jar file
body: <p>I am working on a API system for a program. This system goes to a 'plugin' folder and loads every jar there. I am trying to load the main class of the jar file that is in the 'plugin' folder, but while doing so, I get a ClassNotFoundException.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>private static void loadClassFromJar(String PluginJar) throws MalformedURLException, ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException {
      logger.debug("jar:file:" + "./debug/plugins/DiamondCorePlugin.jar!/");
      URL[] urls = { new URL("jar:file:" + FileList.PluginFolder.getAbsolutePath() + PluginJar +"!/") };
      URLClassLoader ClassLoader = URLClassLoader.newInstance(urls);
      Class&lt;?&gt; Class = ClassLoader.loadClass("net.trenterprises.diamondcore.plugin.Main");
      Object Object = Class.newInstance();
      Method EventMethod = Object.getClass().getMethod("onEnable");
      EventMethod.invoke(Object);
  }
  </code></pre>
  
  <p>If the question is vague or unclear, please let me know (I am new around here, so I try my best to word any question I ask).</p>
  
  <p>EDIT:
  Forgot to include the stack trace. Here it is!</p>
  
  <pre><code>java.lang.ClassNotFoundException: net.trenterprises.diamondcore.plugin.Main
  at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
  at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:798)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  at net.trenterprises.diamondcore.cross.api.PluginLoader.loadClassFromJar(PluginLoader.java:53)
  at net.trenterprises.diamondcore.cross.api.PluginLoader.loadAllPlugins(PluginLoader.java:25)
  at net.trenterprises.diamondcore.DiamondCoreServer.&lt;init&gt;(DiamondCoreServer.java:47)
  at net.trenterprises.diamondcore.run.main(run.java:15)
  </code></pre>