Skip to content

Quick Start: Jupyter Notebook for Java

Yaojin Yang edited this page May 8, 2021 · 3 revisions

Overview

Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and narrative text. It is very popular for learning program languages, data analysis and machine learning, etc. Jupyter Notebook can be used with many programming languages, including Python, R, Julia, and Java too! If you're interested in trying it out with Java, please follow the installation steps below. We look forward to hearing your feedback!

Installation

Step 1. Install VS Code Insiders.

Step 2. Install pre-built binary of Java language kernel for Jupyter notebook, called IJava

Prerequisites :

  • JDK version 9 or above is required; You can check your JDK version by running "java --version" in command window.
  • Python 3 is required to install the Java language kernel. Can be installed from here.
  1. Run " pip install jupyter-client"
  2. Download the release from the release tab. A prepackaged distribution will be in an artifact named ijava-$version.zip.
  3. Unzip it into a temporary location. It should have at least the install.py and java folder extracted in there.
  4. Open terminal and enter into the root directory of the temporary location.
  5. Run " python install.py --user" to install the Java language kernel.

Note: for more details on IJava, you can refer here

Step 3. Install the Jupyter Extension

Step 4. Open or create a notebook file

  1. To create a new notebook open the command palette ( Windows: Ctrl + Shift + P; macOS: Command + Shift + P ) and select the command " Jupyter: Create New Blank Jupyter Notebook"

  2. Select Java as kernel by clicking on the kernel picker in the bottom right of the status bar OR by invoking the " Notebook: Select Notebook Kernel" command.

Picture1

  1. Change the cell language to Java by clicking the language picker OR by invoking the " Notebook: Change Cell Language" command.

Picture2

  1. Type 'System.out.println("Hello, Java");' and click run. You should see "Hello, Java" is printed out below your code.

Step 5. Happy coding with Jupyter!

Feedback

We look forward to your feedback.

Useful commands

Open the Command Palette ( Command+Shift+P on macOS and Ctrl+Shift+P on Windows/Linux ) and type in one of the following commands:

Command Description
Jupyter: Create New Blank Jupyter Notebook Create a new blank Jupyter Notebook
Notebook: Select Notebook Kernel Select or switch kernels within your notebook
Notebook: Change Cell Language Change the language of the cell currently in focus
Jupyter: Export to HTML Jupyter: Export to PDF Create a presentation-friendly version of your notebook in HTML or PDF