title: override java class loader
body: <p>I am having the following example</p>
  
  <pre><code>public class Tester
  {
  
      /**
       * @param args
       * @throws ClassNotFoundException
       */
      public static void main(String[] args) throws ClassNotFoundException
      {
  
          new Tester().execute();
  
      }
  
      private void execute() throws ClassNotFoundException
      {
          //Java Class Loader
          ClassLoader baseClassLoader = Thread.currentThread().getContextClassLoader();
  
          //Java custom Class Loader
          ClassLoader customClassLoader = new CustomClassLoader();
          Class&lt;?&gt; customClass = Class.forName("a.b.c.d.class", true, customClassLoader);
  
          //Java custom Class Loader
          ClassLoader customClassLoader = customClass.getClassLoader();
  
          Thread.currentThread().setContextClassLoader(customClassLoader);
  
          //Java custom Class Loader
          ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();
  
          //Java Class Loader?????
          ClassLoader classLoader = this.getClass().getClassLoader();
      }
  }
  </code></pre>
  
  <p>Why after invoke </p>
  
  <pre><code>Thread.currentThread().setContextClassLoader(customClassLoader);
  </code></pre>
  
  <p>once I execute </p>
  
  <pre><code>this.getClass().getClassLoader(); 
  </code></pre>
  
  <p>I still get the java class loader and not my custom class loader.</p>
  
  <p>How I can do this?</p>
  
  <p>Thanks</p>