Java Environment

This notebook describes and creates the Java environment in Nextjournal. Check out the showcase if you want to see what the environment contains. To see how it’s built, see setup.

Showcase

Maven dependencies can be loaded at runtime. Additional Jupyter 'magics' are documented here.

%maven org.knowm.xchart:xchart:3.5.2
import org.knowm.xchart.*;
double[] xData = new double[] { 0.0, 1.0, 2.0 };
double[] yData = new double[] { 3.0, 4.0, 3.0 };
XYChart chart = QuickChart.getChart("Sample Chart", "X", "Y", "y(x)", 
                                    xData, yData);
BitmapEncoder.getBufferedImage(chart);
1.3s
Java Test (Java)
Java

Setup

Build the IJava Environment

url="https://github.com/SpencerPark/IJava/releases/download/v${IJAVA_VERSION}/ijava-${IJAVA_VERSION}.zip"
wget -q --show-progress --progress=bar:force -P /results $url
1.8s
Java (Bash)
ijava-1.3.0.zip
file="graalvm-ce-java${JAVA_VERSION}-linux-amd64-${GRAAL_VERSION}.tar.gz"
path="graalvm/graalvm-ce-builds/releases/download/vm-${GRAAL_VERSION}/${file}"
url="https://github.com/${path}"
wget -q --show-progress --progress=bar:force -P /results $url
19.0s
Java (Bash)
graalvm-ce-java11-linux-amd64-19.3.1.tar.gz
mkdir $GRAAL_DIR
tar -zxf 
graalvm-ce-java11-linux-amd64-19.3.1.tar.gz
\
  -C $GRAAL_DIR --strip-components=1
13.0s
Java (Bash)
java -version
1.0s
Java (Bash)
gu install native-image
3.0s
Java (Bash)
cd /tmp
unzip 
ijava-1.3.0.zip
0.9s
Java (Bash)
cd /tmp
python3 install.py --sys-prefix
1.6s
Java (Bash)
jupyter kernelspec list
1.1s
Java (Bash)
rm -rf /tmp/*
0.1s
Java (Bash)
du -hsx /
1.1s
Java (Bash)

Test

String helloWorld = "Hello world!";
helloWorld;
0.2s
Java Test (Java)
Java
Hello world!
Runtimes (2)
Runtime Languages (1)