title: java.lang.NoClassDefFoundError in Plugin System
body: <p>So, i have an program, that i want to expand with plugins or modules.</p>
  
  <p>I load them out of the folder and get a ClassLoader to loop through all files, to see if they have the Super class of my Software</p>
  
  <p>Then i get this exception:</p>
  
  <pre><code> java.lang.NoClassDefFoundError: me/mnjg123/privacy1/de/privacy2/system/core/objects/Feature
          at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_242]
          at java.lang.ClassLoader.defineClass(ClassLoader.java:757) ~[?:1.8.0_242]
          at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[?:1.8.0_242]
          at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) ~[?:1.8.0_242]
          at java.net.URLClassLoader.access$100(URLClassLoader.java:74) ~[?:1.8.0_242]
          at java.net.URLClassLoader$1.run(URLClassLoader.java:369) ~[?:1.8.0_242]
          at java.net.URLClassLoader$1.run(URLClassLoader.java:363) ~[?:1.8.0_242]
          at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_242]
          at java.net.URLClassLoader.findClass(URLClassLoader.java:362) ~[?:1.8.0_242]
          at java.lang.ClassLoader.loadClass(ClassLoader.java:419) ~[?:1.8.0_242]
          at java.lang.ClassLoader.loadClass(ClassLoader.java:352) ~[?:1.8.0_242]
          at me.mnjg123.ragemade.de.bungee.system.core.handlers.FeatureHandler.loadFeatures(FeatureHandler.java:88) ~[?:?]
          at me.mnjg123.privacy1.de.privacy2.system.core.privacy3.addFeature(privacy3.java:40) ~[?:?]
          at me.mnjg123.privacy1.de.privacy2.system.core.privacy3.onEnable(privacy3.java:33) ~[?:?]
  Caused by: java.lang.ClassNotFoundException: me.mnjg123.privacy1.de.privacy2.system.core.objects.Feature
          at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[?:1.8.0_242]
          at java.lang.ClassLoader.loadClass(ClassLoader.java:419) ~[?:1.8.0_242]
          at java.lang.ClassLoader.loadClass(ClassLoader.java:352) ~[?:1.8.0_242]
  </code></pre>
  
  <p>This is my ClassLoader:</p>
  
  <pre><code>public List&lt;Feature&gt; loadFeatures() throws FeatureExeption {
  
              List&lt;Feature&gt; features = new ArrayList&lt;&gt;();
  
              try {
  
                  String path = new File("").getAbsolutePath();
                  File folder = new File(path + "/plugins/privacy3/addons/");
                  if(!folder.exists())
                      folder.mkdirs();
                    File[] files = folder.listFiles();
                    if (files != null) {
                      for (File plugin : files) {
                        ZipInputStream zip = new ZipInputStream(new FileInputStream(plugin));
                        List&lt;String&gt; classes = new ArrayList&lt;&gt;();
  
                        for(ZipEntry entry = zip.getNextEntry(); entry != null; entry = zip.getNextEntry()) {
                            if(!entry.isDirectory() &amp;&amp; entry.getName().endsWith(".class")) {
                                String className = entry.getName().replace("/", ".");
  
                                classes.add(className.substring(0, className.length() - ".class".length()));
                            }
                        }
  
                        URLClassLoader classloader = new URLClassLoader(new URL[]{plugin.toURI().toURL()});
  
  
                        for(String className : classes) {
  
  
                      line 88 -&gt;    Class&lt;?&gt; cl = classloader.loadClass(className);
  
                        }
  
                       zip.close();
                       classloader.close();
                      }
                    }
  
              } catch (IOException | ClassNotFoundException  e) {
  
                  e.printStackTrace();
              }
  
              return features;
  
          }
  </code></pre>
  
  <p>and this is the Class i want to load</p>
  
  <pre><code>package me.mnjg123.featuretest;
  
  import me.mnjg123.privacy1.de.privacy2.system.core.objects.Feature;
  
  /**
   * @author mnjg123
   *
   */
  public class PayLoad extends Feature {
  
  
  
  
      /**
       * @param name
       */
      public PayLoad() {
  
          super("test", false);
  
      }
  
      @Override
      public void onEnable() {
          System.out.println("true");
  
          super.onEnable();
      }
  
  
  
  }
  </code></pre>
  
  <p>What do i do wrong? And how can i improve it?</p>