To spawn TIBCO Enterprise Runtime for R engines in a separate process

The terrJava package has been extended with the Java class com.tibco.terr.TerrJavaRemote, which can be used to spawn a TIBCO Enterprise Runtime for R engine running in a separate process, send commands to this engine, and get or set data objects to this engine.

The com.tibco.terr.TerrJavaRemote class contains methods similar in name and behavior to the methods of the TerrJava class that creates an embedded TIBCO Enterprise Runtime for R engine within the Java process. One important difference is that the TerrJava methods are static class methods instead of object methods, because they control the (single) TIBCO Enterprise Runtime for R engine within the process. In contrast, it is possible to create multiple TerrJavaRemote objects, each connected to and controlling a separate spawned TIBCO Enterprise Runtime for R engine process.

Following are some reasons to use TerrJavaRemote objects rather than TerrJava.
  • You can access more than one TIBCO Enterprise Runtime for R engine at a time.
  • You can use TIBCO Enterprise Runtime for R from a Java application, where it is inconvenient or impossible to set the appropriate environment variables needed to run TIBCO Enterprise Runtime for R within the Java process.
  • You can spawn TIBCO Enterprise Runtime for R within a Java JVM separate from the one containing the TerrJavaRemote object. For example, you can spawn a 64-bit Java and TIBCO Enterprise Runtime for R process from a 32-bit Java application.

Like the TerrJava class, the TerrJavaRemote class is defined in TERR_HOME/library/terrJava/java/terrJava.jar, and documentation is available in TERR_HOME/library/terrJava/doc/javadoc/index.html. TerrJavaRemote includes methods for sending expressions to be evaluated in TIBCO Enterprise Runtime for R, adding hooks for capturing TIBCO Enterprise Runtime for R text input and output, and interrupting a running computation. There are also methods for transferring TerrData objects going to or coming from the TIBCO Enterprise Runtime for R engine.

TerrJavaRemote methods are thread-safe, so a Java application could create and access multiple TerrJavaRemote objects in separate Java threads. These methods (except for interrupt) use Java synchronization so only one thread can manipulate a given engine at a time. Separate TerrJavaRemote objects can access separate TIBCO Enterprise Runtime for R engines at once without any interaction between these engines.