Nextjournal / Jan 23 2020
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.2import 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 $url1.8s
Java (Bash)
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 $url19.0s
Java (Bash)
mkdir $GRAAL_DIRtar -zxf graalvm-ce-java11-linux-amd64-19.3.1.tar.gz \ -C $GRAAL_DIR --strip-components=113.0s
Java (Bash)
java -version1.0s
Java (Bash)
gu install native-image3.0s
Java (Bash)
cd /tmpunzip ijava-1.3.0.zip0.9s
Java (Bash)
cd /tmppython3 install.py --sys-prefix1.6s
Java (Bash)
jupyter kernelspec list1.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!