Using Java in Jupyter

Installation of the IJava kernel was very simple. Steps:

curl -LO https://github.com/SpencerPark/IJava/releases/download/v1.3.0/ijava-1.3.0.zip
unzip -d ijava ijava-1.3.0.zip
cd ijava
python install.py --sys-prefix
jupyter kernelspec list which

Or from source:

git clone https://github.com/frankfliu/IJava.git
cd IJava/
./gradlew installKernel

Now i can start jupyter lab as normal and start a Java notebook. As an example, I can run below code.

import org.knowm.xchart.*;
import org.knowm.xchart.style.colors.*;
import java.awt.Color;

double[] xData = new double[] { 0.0, 1.0, 2.0 };
double[] yData = new double[] { 2.0, 1.0, 0.0 };
XYChart chart = QuickChart.getChart("Sample Chart", "X", "Y", "y(x)", xData, yData);
chart.getStyler().setChartBackgroundColor(Color.WHITE);

BitmapEncoder.getBufferedImage(chart);