It's all in the API documentation for the JavaCompiler interface. There's even an example of a SimpleJavaObject implementation that delivers the source given a String (i.e. no actual file is needed)....