Hi, Iam doing a project to monitor the invocation of each package in a Java application. Iam sending each call to a function to my own method where I want to execute it. Iam passing the function call as a string to my function. I would like to know how will I be able to execute the string. for example: if we have System.out.println("Hello World"); in the original code. then Iam modifying the code as mypackage.monitor("System.out.println("Hello World"); "); where mypackage is the package containing the method monitor. I would like to know how can I execute the command in monitor method and then go to the next line in the original source code. Will anybody please help me. -Parwez
hi i think u r doing it wrong way. u can't do it the way u r trying. because when u r passing the statement as an string it is getting compiled as a string. no way it can give u correct results. moreover u extract statement in the monitor method but its not compiled as a java statement, it can't run. u can run operating system commands like that but once compiler has done its job and code is handed over to the interpretter it can't come back to compiler by itself just for 1 or 2 statements. think some other way out for your application. harish
Looks like the Method class (java.lang.reflect, JDK 1.2.2) may be of some help, as would the java.lang.Class class. You would then have object references that you could pass to monitor() to have it execute the given Method in a given Class or something similar.