Sometimes (but not always) this is a symptom of problem with program design. Could you please tell us why you are wishing to do this? What is the overall goal of this portion of the program.
Starting with Java 6, there's an official API for compiling Java source code. Earlier JDK versions require some trickery. Check the Java Intermediate FAQ for some links on this.
The api looks great also JEL might also prove to be a help in achieving what i am trying.
And pete i agree the solution involving compiling the class on the fly is a dirty fix most of time but i know exactly why it's been required in my case.