• 703-743-9010
  • info@oneoffcoder.com
  • 7526 Old Linton Hall Rd, Gainesville VA, 20155

Learn Java 12 with Jupyter Lab

Learning Java 12 can be a challenge since you will have to set up your development environment correctly. We have released a Docker container with Java 12 and Jupyter Lab to take away the pain of creating a Java environment and setting up an Integrated Development Environment (IDE). With this Docker container, you can quickly prototype your code and learn Java 12 easily. The Docker container is published to Docker Hub and the source code is available on GitHub. The proof is in the pudding; take a look at the sample notebook below.

Hello, world!

In [1]:
System.out.println("Hello, world!");
Hello, world!

Simple list operation

In [2]:
import java.util.*;

List<String> names = Arrays.asList("john", "jane");

names.forEach(name -> System.out.println(name));
john
jane

Maven dependencies, cell magics

In [3]:
%%loadFromPOM
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-math3</artifactId>
    <version>3.6.1</version>
</dependency>
In [4]:
import org.apache.commons.math3.fraction.*;

Fraction.FOUR_FIFTHS.percentageValue();
Out[4]:
80.0

Maven dependencies, line magic

In [5]:
%maven org.knowm.xchart:xchart:3.6.0

import org.knowm.xchart.*;

double[] x = new double[] { 0.0, 1.0, 2.0 };
double[] y = new double[] { 2.0, 1.0, 0.0 };

XYChart chart = QuickChart.getChart("Sample", "X", "Y", "y(x)", x, y);

BitmapEncoder.getBufferedImage(chart);
Out[5]:
In [ ]: