Using TERR, the terrJava Package, and Java
The terrJava package is included in TIBCO® Enterprise Runtime for R (TERR™).
The terrJava package supports calls between Java code and TERR™ code in both directions:
- R code within
TERR can call Java static methods using the
.JavaMethod
function. - A Java application can start an embedded TERR engine and send expressions to be parsed and evaluated in TERR.
- A Java application can spawn a separate Java process with an embedded TERR engine, and control it just as if it were embedded in the same process.
Initially, we created this package for internal use only to support running TERR engines within the TIBCO Spotfire® Statistics Services server. However, others have expressed an interest to use terrJava to embed TERR in other Java applications. This document provides pointers so programmers can try this embedding using TERR and terrJava.
This document is divided into three main sections:
- Calling from TERR into Java.
- embedding TERR within Java.
- Spawning a separate Java process with an embedded TERR engine.
We suggest that a new user review these sections in order, testing that calling Java from
TERR works correctly before trying the more complex task of embedding
TERR within a Java process. This can be done by creating multiple Java processes with embedded
TERR engines and managing communication between them. Alternatively, one 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 TIBCO Enterprise Runtime for R.
- To Call into Java from TIBCO Enterprise Runtime for R
terrJava and TERR work with Java in the same process. - To Embed the TIBCO 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. - To Spawn TIBCO Enterprise Runtime for R Engines in a Separate Process
The terrJava package has been extended with the Java classcom.tibco.terr.TerrJavaRemote
, which can be used to spawn a TERR engine running in a separate process, send commands to this engine, and get or set data objects to this engine. - Signal Handlers
TERR supports installing signal handlers to catch illegal operations that occur in foreign code called via the.C()
or.Call()
functions. - To Call Embedded TIBCO Enterprise Runtime for R from an IntelliJ Project
Using the IntelliJ IDE to debug your Java application could require a workaround.
- To Call into Java from TIBCO Enterprise Runtime for R
terrJava and TERR work with Java in the same process. - To Embed the TIBCO 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. - To Spawn TIBCO Enterprise Runtime for R Engines in a Separate Process
The terrJava package has been extended with the Java classcom.tibco.terr.TerrJavaRemote
, which can be used to spawn a TERR engine running in a separate process, send commands to this engine, and get or set data objects to this engine. - Signal Handlers
TERR supports installing signal handlers to catch illegal operations that occur in foreign code called via the.C()
or.Call()
functions. - To Call Embedded TIBCO Enterprise Runtime for R from an IntelliJ Project
Using the IntelliJ IDE to debug your Java application could require a workaround.