Dynamically compiling scala class files at runtime in Scala 2.11

If your goal is to run external scala classes in runtime, I’d suggest using eval with scala.tools.reflect.ToolBox (it is included in REPL, but for normal usage you have to add scala-reflect.jar): import scala.reflect.runtime.universe import scala.tools.reflect.ToolBox val tb = universe.runtimeMirror(getClass.getClassLoader).mkToolBox() tb.eval(tb.parse(“””println(“hello!”)”””)) You also can compile files, using tb.compile. Modified with example: assume you have external file … Read more