# To Embed the Spotfire Enterprise Runtime for R Engine within a Java Application

The terrJava package supports starting a TERR engine from Java, and then sending expressions for TERR to evaluate.

Setting this up is more complicated than starting Java from TERR by executing `library(terrJava)`, but it has proven useful for Java applications that need to call TERR computations.

Note: The TERR engine is single-threaded, so it is not possible to run more than one TERR engine at the same time within a given operating system process. If your Java application wants to create multiple TERR engines, the application must create the engines in multiple operating system processes. This can be done by creating multiple Java processes with embedded TERR engines, and managing communication between them. Alternatively, you can use the `TerrJavaRemote` class to spawn and control multiple processes with embedded TERR engines, as described in Setting up environment variables for a Java application to use Spotfire Enterprise Runtime for R.