Calls a Java method, transferring R arguments to the Java (Omegahat)
system as needed. This can be used to call methods in the Omegahat
evaluator, not just on previously created user-level objects. One
must create and initialize the Java virtual machine before calling
this function. See .JavaInit.
.Java(.qualifier, .methodName, ..., .name=NULL, .sigs="", .convert=TRUE).Java or
.JavaConstructor. If this is NULL or omitted, the
Omegahat evaluator looks first for an Omegahat function and then a
method within its own object..qualifier is NULL) that is to be invoked in the Java
object..Java calls..JavaSigs for possible values.TRUE, but can be explicitly specified
to avoid (arrays of) primitive object being converted to an R object
when it is to be used in a subsequent .Java call. One can
also provide a function which will be called with two arguments - a
reference to the Java object and the class name of the Java object.
This is the same as the function converters one can register via
setJavaFunctionConverter. Also, one can specify a native routine (i.e. C/C++/Fortran)
address. This can be done using
getNativeSymbolInfo and accessing the
address field of the returned object. See examples in the
inst/examples/ directory.
.name argument was supplied in the call to this
R function, the reference is a NamedReference. Otherwise, it is
a AnonymousReference.This invokes a Java method on the target object by first converting the R arguments to Java objects and then searching the Java object for a method that accepts these Java argument types. Then it invokes the method and converts the result to a Java object using the basic and extensible conversion mechanism between Java and R.
.JavaConstructor
.OmegahatExpression
getJavaConverterDescriptions v <- .JavaConstructor("java.util.Vector", as.integer(10))
.Java(v, "add", "A string element")
.Java(v, "add", .JavaConstructor("java.util.Hashtable", as.integer(3)))
.Java(v, "size")
props <- .Java("System", "getProperties")
props[["java.class.path"]]
props <- .Java("System", "getProperties", .convert=FALSE)
props$getProperty("java.class.path")
Run the code above in your browser using DataLab