Thread.currentThread().setContextClassLoader without using reflection
<p>I have a "com.test.Test1" class which is in test.jar. I use this jar for compiling but does not deploy with my webapp. I want my servlet loading this jar dynamically during runtime.</p>

<p>Is there any way to load the classes dynamically without using Java reflection? the reason why I ask this is because I don't want to convert tons of my existing code to java reflection. </p>

<pre><code>public class servlet1 extends HttpServlet {

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,IOException {

        URLClassLoader urlClassLoader = new URLClassLoader(new URL[] { new File("test.jar").toURI().toURL() }, null);
        Thread.currentThread().setContextClassLoader(urlClassLoader);
         Class c = newClassLoader.loadClass("com.test.Test1");

        //////
        Test1 test1 = new Test1() ==&gt; ClassNotFound Exception
        test1.testMeothod();
        ///////    

        // if using java reflection will work
        c.newInstance() ...........
        Method m = c.getDeclaredMethod("startup", null);
        .....
        .....
        //////    
    }
}
</code></pre>
