Spotfire® Enterprise Runtime for R

Run the Console Application

After you create the console application, you can test it using example user input and text output on Linux.

seaqal6406 ~% setenv JAVA_HOME /usr/lib/jvm/java-6-sun/
seaqal6406 ~% setenv TERR_HOME /opt/sw/test/daily/intel
seaqal6406 ~% setenv CLASSPATH
  $TERR_HOME/library/terrJava/java/terrJava.jar:/homes/jdoe/TerrConsoleExample
seaqal6406 ~% setenv LD_LIBRARY_PATH
  $TERR_HOME/lib/x86_64-unknown-linux:$LD_LIBRARY_PATH
seaqal6406 ~% $JAVA_HOME/bin/java TerrConsoleExample
TerrConsoleExample: 
> # simple comments do nothing
> 1:10
 [1]  1  2  3  4  5  6  7  8  9 10
>
> # terrJava is automatically loaded,
> # so you can call .JavaMethod
> .JavaMethod("java/lang/Math", "pow", "(DD)D", 2, 3)
[1] 8
>
> # call readline, which calls input handler
> # to read a line
> x <- readline()
typing in a new line
> x
[1] "typing in a new line"
>
> # change prompt string, then change it back
> options(prompt="newprompt--> ")
newprompt--> 1+2
[1] 3
newprompt--> options(prompt="> ")
>
> # handle incomplete expression
> # by accumulating multiple lines
> 1+(2
+ +3)
[1] 6
>
> # handle incomplete string
> # by accumulating multiple lines
> nchar("abcd
Continue string: efg")
[1] 8
>
> # error is printed out
> stop("foo")
Error: foo
> # traceback() gives stack from last error
> traceback()
1: stop("foo")
>
> # quit from engine
> q()
seaqal6406 ~%