JClass: Returns a reference to a Java class.

Description Usage Arguments Details Value Author(s) References See Also Examples

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

1

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.

Details

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

Value

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

Author(s)

Duncan Temple Lang, John Chambers

References

http://www.omegahat.org/RSJava

See Also

.Java

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
  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())

SJava documentation built on Oct. 5, 2016, 4:17 a.m.

Related to JClass in SJava...