Java interpreter for Apache Zeppelin
How to use
Basically, you can write normal java code. You should write the main method inside a class because the interpreter invoke this main to execute the code. Unlike Zeppelin normal pattern, each paragraph is considered as a separate job, there isn't any relation to any other paragraph. For example, a variable defined in one paragraph cannot be used in another one as each paragraph is a self contained java main class that is executed and the output returned to Zeppelin.
The following is a demonstration of a word count example with data represented as a java Map and displayed leveraging Zeppelin's built in visualization using the utility method JavaInterpreterUtils.displayTableFromSimpleMap
.
%java
import java.util.HashMap;
import java.util.Map;
import org.apache.zeppelin.java.JavaInterpreterUtils;
public class HelloWorld {
public static void main(String[] args) {
Map<String, Long> counts = new HashMap<>();
counts.put("hello",4L);
counts.put("world",5L);
System.out.println(JavaInterpreterUtils.displayTableFromSimpleMap("Word","Count", counts));
}
}