Examples for 'rJava::J'


High level API for accessing Java

Aliases: J

Keywords: interface

### ** Examples

## Don't show: 
.jinit()
## End(Don't show)

if (!nzchar(Sys.getenv("NOAWT"))) {
  f <- new(J("java.awt.Frame"), "Hello")
  f$setVisible(TRUE)
}
Error in .jcall("RJavaTools", "Ljava/lang/Object;", "newInstance", class, : java.awt.HeadlessException: 
No X11 DISPLAY variable was set, but this program performed an operation which requires it.
J("java.lang.Double")$parseDouble("10.2")
[1] 10.2
J("java.lang.Double", "parseDouble", "10.2" )
[1] 10.2
Double <- J("java.lang.Double")
Double$parseDouble( "10.2")
[1] 10.2
# String[] strings = new String[]{ "string", "array" } ;
  strings <- .jarray( c("string", "array") )
# this uses the JList( Object[] ) constructor 
# even though the "strings" parameter is a String[] 
  l <- new( J("javax.swing.JList"), strings)

[Package rJava version 1.0-6 Index]