Adding a 'complete' example based on stephen answer+comment:
public static void main(String[] args) throws ScriptException, ExecutionException, InterruptedException {
Graph graph = TinkerGraph.open();
Configuration c = graph.configuration();
GraphTraversalSource g = graph.traversal();
// Creating graph
Vertex marko = g.addV("person").property("name","marko").property("age",29).next();
Vertex lop = g.addV("software").property("name","lop").property("lang","java").next();
g.addE("created").from(marko).to(lop).property("weight",0.6d).iterate();
g.io("test.xml").write().iterate(); // saving to file
//standard query
GraphTraversal<Vertex, Map<Object, Object>> javaQueryResult = g.V().hasLabel("person").valueMap();
// preparing GremlinExecutor
ConcurrentBindings b = new ConcurrentBindings();
b.putIfAbsent("g", g);
GremlinExecutor ge = GremlinExecutor.build().evaluationTimeout(15000L).globalBindings(b).create();
CompletableFuture<Object> evalResult = ge.eval("g.V().hasLabel('person').valueMap()");
GraphTraversal actualResult = (GraphTraversal) evalResult.get();
}
Simple debugging app to check how results evaluated from string compare to standard queries.
Using maven dependencies tinkergraph-gremlin
gremlin-core
gremlin-groovy
, version 3.4.6