Create a Java object
jnew.Rd.jnew create a new Java object.
Arguments
- class
fully qualified class name in JNI notation (e.g.
"java/lang/String").- ...
Any parameters that will be passed to the corresponding constructor. The parameter types are determined automatically and/or taken from the
jobjRefobject. For details see.jcall. Note that all named parameters are discarded.- check
If set to
TRUEthen.jcheckis invoked before and after the call to the constructor to clear any pending Java exceptions.- silent
If set to
FALSEthen.jnewwill fail with an error if the object cannot be created, otherwise a null-reference is returned instead. In addition, this flag is also passed to final.jcheckifcheckabove is set toTRUE. Note that the error handling also clears exceptions, socheck=FALSE, silent=FALSEis usually not a meaningful combination.- class.loader
optional class loader to force for loading the class. If not set, the rJava class loader is used first. The default Java class loader is always used as a last resort. Set to
.rJava.class.loaderinside a package if it uses its own class loader (see.jpackagefor details).
Value
Returns the reference (jobjRef) to the newly created object or
null-reference (see .jnull) if something went wrong.
Examples
if (FALSE) { # \dontrun{
f <- .jnew("java/awt/Frame","Hello")
.jcall(f,,"setVisible",TRUE)
} # }