Dynamically loading class problem

I have a test class

public class test

{

public String getMsg(String msg)

{

return msg;

}

}

and i have a Test123 class

import java.lang.reflect.Method;

public class Test123

{

public String getMsg(String msg)

{

Object test;

Object param[]=new Object[1];

param[0]=msg;

String a="";

String path="/usr/testfolder/test";

try

{

test = Class.forName(path).newInstance() ;

Method aMethod = test.getClass().getMethod("getMsg", new Class[]{a.getClass()});

a = aMethod.invoke(test, param).toString();

}

catch(Exception e)

{

System.out.println(e.getMessage());

}

return a;

}

public static void main(String[] args)

{

System.out.println(new Test123().getMsg("hello"));

}

}

When the path="test", it is working,

but when i set the path="/usr/testfolder/test", it is not working.

Can anyone help me out of this?

thanks.

[1043 byte] By [netangela] at [2007-11-26 12:32:48]
# 1
The class is called test, regardless of the directory which contains it. If you want to specify a path, use a URLClassLoader with the path as a file:/// URL, and load the class' name with that loader.
YAT_Archivista at 2007-7-7 15:46:15 > top of Java-index,Core,Core APIs...