Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > General Computer Support > problem with the adding jars dynamically

Thread Tools

problem with the adding jars dynamically

kmurthy7 kmurthy7 is offline
Junior Member
Join Date: Feb 2009
Posts: 1
I am trying to add a jar dynamically to the class path. and then invoking a one of the class method defined in the jar file. It is not giving any error while executing the code but its not performing the action specified in the method.

The following is the code i have written.

package com.netenrich.msp.web.tags;

import java.lang.reflect.Method;

import PluginClassLoader1;
import plugin.PluginServlet;

public class Test {

public static void main(String args[]) throws Exception {
System.out.println(" start ...");
PluginClassLoader1 classLoader = new PluginClassLoader1();
Class clas = Class.forName("testplugin.NameServlet");
Object obj = clas.newInstance();
Method m[] = clas.getMethods();
for(Method mm : m) {
mm.invoke(obj, new Object[]{null,null});
PluginServlet ps = (PluginServlet)clas.newInstance();
ps.handleRequest(null, null);
System.out.println(" end ...");

public class NameServlet implements PluginServlet {

public String handleRequest(HttpServletRequest request,
HttpServletResponse response) throws Exception {
System.out.println(" I am in Name servlet ");
return "/jsp/name.jsp";


when i run the above code i am not seeing the 'I am in Name servlet' message in the console.
and also return string is just ''.

Can some one please tell me what i am doing wrong here.

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Add *.jars to *.jars possible/recommendend? Eclipse setup for this? Ulf Meinhardt Java 2 02-03-2010 04:11 PM
Loading image from jars from other jars etc JavaEnquirer Java 2 02-22-2006 03:42 PM
JARs containing JARs Java 5 05-19-2005 04:55 PM
adding jars to classpath on runtime without -cp option rony Java 8 11-30-2004 01:00 PM
exec jars w/dependent jars Ike Java 6 09-24-2004 06:03 PM