blob: 4991909cf8887608940e938731ccdbd028c40500 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>R: Call Static Java Methods</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="R.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/styles/github.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.3/languages/r.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
</head><body>
<table width="100%" summary="page for sparkR.callJStatic {SparkR}"><tr><td>sparkR.callJStatic {SparkR}</td><td align="right">R Documentation</td></tr></table>
<h2>Call Static Java Methods</h2>
<h3>Description</h3>
<p>Call a static method in the JVM running the Spark driver. The return
value is automatically converted to R objects for simple objects. Other
values are returned as &quot;jobj&quot; which are references to objects on JVM.
</p>
<h3>Usage</h3>
<pre>
sparkR.callJStatic(x, methodName, ...)
</pre>
<h3>Arguments</h3>
<table summary="R argblock">
<tr valign="top"><td><code>x</code></td>
<td>
<p>fully qualified Java class name that contains the static method to invoke.</p>
</td></tr>
<tr valign="top"><td><code>methodName</code></td>
<td>
<p>name of static method to invoke.</p>
</td></tr>
<tr valign="top"><td><code>...</code></td>
<td>
<p>parameters to pass to the Java method.</p>
</td></tr>
</table>
<h3>Details</h3>
<p>This is a low level function to access the JVM directly and should only be used
for advanced use cases. The arguments and return values that are primitive R
types (like integer, numeric, character, lists) are automatically translated to/from
Java types (like Integer, Double, String, Array). A full list can be found in
serialize.R and deserialize.R in the Apache Spark code base.
</p>
<h3>Value</h3>
<p>the return value of the Java method. Either returned as a R object
if it can be deserialized or returned as a &quot;jobj&quot;. See details section for more.
</p>
<h3>Note</h3>
<p>sparkR.callJStatic since 2.0.1
</p>
<h3>See Also</h3>
<p><a href="sparkR.callJMethod.html">sparkR.callJMethod</a>, <a href="sparkR.newJObject.html">sparkR.newJObject</a>
</p>
<h3>Examples</h3>
<pre><code class="r">## Not run:
##D sparkR.session() # Need to have a Spark JVM running before calling callJStatic
##D sparkR.callJStatic(&quot;java.lang.System&quot;, &quot;currentTimeMillis&quot;)
##D sparkR.callJStatic(&quot;java.lang.System&quot;, &quot;getProperty&quot;, &quot;java.home&quot;)
## End(Not run)
</code></pre>
<hr><div align="center">[Package <em>SparkR</em> version 2.1.1 <a href="00Index.html">Index</a>]</div>
</body></html>