javascalaocamlabstract-syntax-tree

How to execute OCaml code from Scala/Java?


I'm about to write an abstract syntax for OCaml in scala, in combination with a pretty printer. After that I want execute the generated OCaml code from scala and work with the result.

Is there a way to do that, without running a external OCaml compiler, execute the program and reading the result from stdout?


Solution

  • If you want to call external processes from Scala, take a look on the built-in processes DSL. It's pretty nice.

    You can also fall back to the simple Java solutions (i.e., ProcessBuilder or Runtime.exec()).