SJava (version 0.98.0)

isJavaInitialized: Determines whether the JVM has been created.

Description

This determines whether the Java Virtual machine has already been initialized within this R session, usually via the .JavaInit This is useful when we want to use the Java interface, but want to avoid an error being thrown if the user hasn't already created Java.

Usage

isJavaInitialized(msg=NULL)

Arguments

msg
A character string, which if specified and the virtual machine has not been initialized, is passed as the single argument in a call to stop.

Value

A logical value indicating whether the JVM has been created earlier (TRUE) or not (FALSE). If the msg argument is specified and the JVM has not been initialized, an error is thrown and there is no return value.

Details

This checks the state of the internal C variables to determine if the user has initialized the JVM. It does not attempt to create the JVM. This allows the user to specify different arguments to customize the VM.

References

http://www.omegahat.org/RSJava

See Also

.JavaInit

Examples

Run this code
  isJavaInitialized("initialize Java with .JavaInit()")
  jlabel <- .JavaConstructor("javax.swing.JButton",
                             "Welcome the R-Java interface")
  f <- .JavaConstructor("org.omegahat.Environment.GUITools.GenericFrame", 
                        jlabel, TRUE)

    # optionally execute code.
 if(isJavaInitialized()) {
   .Java("System", "getProperty", "java.class.path")
 }

Run the code above in your browser using DataLab