Skip to content

Instantly share code, notes, and snippets.

@SpencerPark
Last active April 18, 2023 14:19
Show Gist options
  • Save SpencerPark/447de114fcd3e6a272dc140809462e30 to your computer and use it in GitHub Desktop.
Save SpencerPark/447de114fcd3e6a272dc140809462e30 to your computer and use it in GitHub Desktop.
A base notebook to install the IJava kernel (and ipc proxy) in google colab. Based on https://gist.github.com/tueda/a200b3f747d0fc864be8b4dd09be5a1e
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "IJava.ipynb",
"provenance": []
},
"kernelspec": {
"name": "java",
"display_name": "Java"
},
"language_info": {
"name": "java"
},
"gpuClass": "standard"
},
"cells": [
{
"cell_type": "markdown",
"source": [
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/gist/SpencerPark/447de114fcd3e6a272dc140809462e30)"
],
"metadata": {
"id": "grpzdqlQ0rsL"
}
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "IrB2Kt3NqXec"
},
"outputs": [],
"source": [
"%%sh\n",
"# Install java kernel\n",
"wget -q https://github.com/SpencerPark/IJava/releases/download/v1.3.0/ijava-1.3.0.zip \n",
"unzip -q ijava-1.3.0.zip \n",
"python install.py\n",
"\n",
"# Install proxy for the java kernel\n",
"wget -qO- https://gist.github.com/SpencerPark/e2732061ad19c1afa4a33a58cb8f18a9/archive/b6cff2bf09b6832344e576ea1e4731f0fb3df10c.tar.gz | tar xvz --strip-components=1\n",
"python install_ipc_proxy_kernel.py --kernel=java --implementation=ipc_proxy_kernel.py"
]
},
{
"cell_type": "code",
"source": [
"System.out.println(\"Are you ready?:\");\n",
"\n",
"BufferedReader buffer = new BufferedReader(new InputStreamReader(System.in));\n",
"String line = buffer.readLine();\n",
"\n",
"if (!line.equalsIgnoreCase(\"yessir\"))\n",
" throw new IllegalArgumentException(\"'yessir' is the only acceptable answer.\");\n",
"\n",
"String id = display(\"<b>Countdown:</b> 3\", \"text/html\");\n",
"for (int i = 3; i >= 0; i--) {\n",
" updateDisplay(id, \"<b>Countdown:</b> \" + i, \"text/html\");\n",
" Thread.sleep(1000L);\n",
"}\n",
"render(\"<b>Liftoff!</b>\", \"text/html\")"
],
"metadata": {
"id": "H1zYoTexsONt"
},
"execution_count": null,
"outputs": []
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment