Introduction to using terrJava

The terrJava package is included in TIBCO® Enterprise Runtime for R.

The terrJava package supports calls between Java code and TIBCO Enterprise Runtime for R code in both directions:

  • S code within TIBCO Enterprise Runtime for R can call Java static methods using the .JavaMethod function.
  • A Java application can start an embedded TIBCO Enterprise Runtime for R engine and send expressions to be parsed and evaluated in TIBCO Enterprise Runtime for R.
  • A Java application can spawn a separate Java process with an embedded TIBCO Enterprise Runtime for R 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 TIBCO Enterprise Runtime for R engines within the TIBCO Spotfire® Statistics Services server. However, others have expressed an interest to use terrJava to embed TIBCO Enterprise Runtime for R in other Java applications. This document provides pointers so programmers can try this embedding using TIBCO Enterprise Runtime for R and terrJava.

Note: The terrJava package is subject to change. If the current package does not supply everything that programmers need, the TIBCO Enterprise Runtime for R development group would like know, so we can improve and extend terrJava.

This document is divided into three main sections:

  • Calling from TIBCO Enterprise Runtime for R into Java.
  • embedding TIBCO Enterprise Runtime for R within Java.
  • Spawning a separate Java process with an embedded TIBCO Enterprise Runtime for R engine.

We suggest that a new user review these sections in order, testing that calling Java from TIBCO Enterprise Runtime for R works correctly before trying the more complex task of embedding TIBCO Enterprise Runtime for R within a Java process. This can be done by creating multiple Java processes with embedded TIBCO Enterprise Runtime for R engines and managing communication between them. Alternatively, one can use the TerrJavaRemote class to spawn and control multiple processes with embedded TIBCO Enterprise Runtime for R engines, as described in Setting up environment variables for a Java application to use TIBCO Enterprise Runtime for R.