SJava (version 0.98.0)

.JClass: Returns a reference to a Java class.

Description

This returns the class of the specified object or that found by resolving the (partially qualfied) class name. The resulting class reference can be used to access static fields and method, and a description of the class. This is most conveniently done using the $ operator.

Usage

.JClass(x, name = NULL)

Arguments

x
a (partially qualified) class name or a reference to a Java object whose class name is used to resolve the class.
name
an optional string to use as the name to use for the resulting class reference in the Omegahat database. This is passed as the .name argument to .Java.

Value

An anonymous reference to a Java class. This can then be used to access static methods and fields.

Details

This calls the Omegahat evaluator's findClass method with the name of the class to be found.

References

http://www.omegahat.org/RSJava

See Also

.Java

Examples

Run this code
  jsys <- .JClass("System")
  jsys$getProperties()
  jsys$getProperty("java.class.path")

   rt <- .JClass("Runtime")$getRuntime()
   rt$exec("whoami")
   rt$exec(paste("find",system.file("scripts", pkg="Java")))

   frame <- .JNew("JFrame")
   frame$setBackground(.JClass("Color")$red())

Run the code above in your browser using DataCamp Workspace