Class loaded but not loaded for the demo program Trace

I'm extending the program Trace of the jpda example, trying to add dynamic class load funtion in it, without using the command line to set the classpath.

Here below is the construction method,

I used personalized classloader to load a class and pass it to the constructor of Trace

public Trace(Class classe){

vm =null;

System.out.println(classe.getName());

Class mainArgType[] ={(new String[0]).getClass()};

try{

java.lang.reflect.Method main = classe.getMethod("main", mainArgType);

System.out.println("main: " + main.toString());

String progArg[] ={""};

Object mainArg[] ={progArg};

main.invoke(null, mainArg);

}

catch (NoSuchMethodException ex){

System.out.println("nessun metodo");

}

in tre previous part, the loaded class is loaded and executed, but when I continue to the following code

vm = launchTarget(classe.getName());

PrintWriter writer =new PrintWriter(System.out);

generateTrace(writer);

}

It gave me a java.lang.NoClassDefFoundError, how come?

Although the methods of launchTarget and others were left unchanged.

Is there any answer to this?

Or can I get another approach to this tracing problem?

[1888 byte] By [xa_l_ix] at [2007-9-30 16:25:36]
# 1
On what line did you get the error?It would help if you posted the whole exception stacktrace.
sangretu at 2007-7-6 0:08:18 > top of Java-index,Archived Forums,Debugging Tools and Techniques...
# 2

>

> in tre previous part, the loaded class is loaded and

> executed, but when I continue to the following code

>

No it isn't. All it does is run a method.

> vm = launchTarget(classe.getName());

> PrintWriter writer = new PrintWriter(System.out);

> generateTrace(writer);

> }

>

>

> It gave me a java.lang.NoClassDefFoundError, how come?

No idea because that code wouldn't produce the error.

> Although the methods of launchTarget and others were

> left unchanged.

> Is there any answer to this?

Can you write code to load a class - definitely. Is there a solution to your problem? Probably.

Can we figure it out with the guess that you made as to where the problem is - not a chance.

You call printStackTrace() on the exception. It tells you the exact line where the error occurred.

jschell at 2007-7-6 0:08:18 > top of Java-index,Archived Forums,Debugging Tools and Techniques...