trying to call Java methods from R. I have written Java code for Java-Gremlin interface, which worked well. But now I want to Call the methods to R, so in return I'll get output data from gremlin queries and I can analyse the data. But in '.jcall()' command in R, getting error and hence unable to call the method in R. The following is the java code which have written.
import java.util.Map;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
public class TinkerGraphTest2 {
TinkerGraph tg = null;
GraphTraversalSource g = null;
public static void main(String[] args) {
// TODO Auto-generated method stub
TinkerGraph tg = TinkerGraph.open() ;
System.out.println("Welcome to Eclipse");
try
{
GraphTraversalSource g = tg.traversal();
g.io("D:\\PID\\data\\air-routes.xml").read().iterate();
}
catch( Exception e )
{
System.out.println("File not found");
System.out.println(e);
System.exit(1);
}
}
public String getDallasRoutes(String country) {
Long n = g.V().has("code",country).out().count().next();
return("There are " + n + " routes from" + country);
}
public Map<?, ?> getDetailsofAirports() {
Map<?,?> aus = g.V().has("code","AUS").valueMap().next();
System.out.println(aus.toString());
@SuppressWarnings("rawtypes")
List city = (List)(aus.get("city"));
System.out.println("The AUS airport is in " + city.get(0));
aus.forEach( (k,v) -> System.out.println("Key: " + k + ": Value: " + v));
return aus;
}
}
This code worked well and getting expected output. R code to call method getDallasRoutes().Getting error in '.jcall()'
library(rJava)
.jinit()
cl_path="....."
.jaddClassPath(cl_path)
test=.jnew("TinkerGraphTest2")
x=.jcall(test,returnSig = "S",method="getDallasRoutes","AUS")
##Error in .jcall(test, returnSig = "S", method = "getDallasRoutes", "AUS") :
java.lang.NoClassDefFoundError: org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversalSource
#tried another command also
p=J("TinkerGraphTest2","getDallasRoutes","AUS")
#Error in .jcall("RJavaTools", "Ljava/lang/Object;", "invokeMethod", cl, :
java.lang.IllegalArgumentException: object is not an instance of declaring class
Could you suggest me any solutions? It would be of great help!