-
-
Save torgeir/ae19f93614b3a2636ee059ca66ed8e2b to your computer and use it in GitHub Desktop.
Kotlin.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"nbformat": 4, | |
"nbformat_minor": 0, | |
"metadata": { | |
"colab": { | |
"name": "Kotlin.ipynb", | |
"provenance": [], | |
"collapsed_sections": [], | |
"include_colab_link": true | |
}, | |
"kernelspec": { | |
"name": "kotlin", | |
"display_name": "kotlin" | |
}, | |
"language_info": { | |
"name": "kotlin" | |
} | |
}, | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": { | |
"id": "view-in-github", | |
"colab_type": "text" | |
}, | |
"source": [ | |
"<a href=\"https://colab.research.google.com/gist/torgeir/ae19f93614b3a2636ee059ca66ed8e2b/kotlin.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"metadata": { | |
"id": "kpRt6m9cSbjF", | |
"outputId": "1f5f7a2e-44f3-4084-fb18-ce0092a26094", | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
} | |
}, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"Collecting kotlin-jupyter-kernel\n", | |
" Downloading kotlin_jupyter_kernel-0.11.0.45-py3-none-any.whl (73.1 MB)\n", | |
"Installing collected packages: kotlin-jupyter-kernel\n", | |
"Successfully installed kotlin-jupyter-kernel-0.11.0.45\n", | |
"Collecting install-jdk\n", | |
" Downloading install-jdk-0.3.0.tar.gz (3.8 kB)\n", | |
"Building wheels for collected packages: install-jdk\n", | |
" Building wheel for install-jdk (setup.py): started\n", | |
" Building wheel for install-jdk (setup.py): finished with status 'done'\n", | |
" Created wheel for install-jdk: filename=install_jdk-0.3.0-py3-none-any.whl size=3741 sha256=468278e0530b6f0c3abe9a2143082fc72a0b9c1f360a18afc25b69ab0730aceb\n", | |
" Stored in directory: /root/.cache/pip/wheels/0c/91/c1/8f013bf264e0598257fd7c9e602c971ac005df0d40057bf697\n", | |
"Successfully built install-jdk\n", | |
"Installing collected packages: install-jdk\n", | |
"Successfully installed install-jdk-0.3.0\n", | |
"Available kernels:\n", | |
" ir /usr/local/share/jupyter/kernels/ir\n", | |
" kotlin /usr/local/share/jupyter/kernels/kotlin\n", | |
" python2 /usr/local/share/jupyter/kernels/python2\n", | |
" python3 /usr/local/share/jupyter/kernels/python3\n" | |
] | |
} | |
], | |
"source": [ | |
"!pip install kotlin-jupyter-kernel\n", | |
"!pip install install-jdk\n", | |
"!jupyter-kernelspec list" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"import jdk\n", | |
"jdk.install('11')" | |
], | |
"metadata": { | |
"id": "Dt0uAVRdo2Ae", | |
"colab": { | |
"base_uri": "https://localhost:8080/", | |
"height": 35 | |
}, | |
"outputId": "3615dfd1-ab72-4cd9-c365-0fa08fafc804" | |
}, | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "execute_result", | |
"data": { | |
"application/vnd.google.colaboratory.intrinsic+json": { | |
"type": "string" | |
}, | |
"text/plain": [ | |
"'/root/.jdk/jdk-11.0.14.1+1'" | |
] | |
}, | |
"metadata": {}, | |
"execution_count": 2 | |
} | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"!export PATH=$PATH:/root/.jdk/jdk-11.0.14.1+1/bin" | |
], | |
"metadata": { | |
"id": "yLVeGz3XplZF" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"!java --version" | |
], | |
"metadata": { | |
"colab": { | |
"base_uri": "https://localhost:8080/" | |
}, | |
"id": "sltZbUOopuDJ", | |
"outputId": "a0076ac5-c907-4160-9791-2069a1552a11" | |
}, | |
"execution_count": null, | |
"outputs": [ | |
{ | |
"output_type": "stream", | |
"name": "stdout", | |
"text": [ | |
"openjdk 11.0.13 2021-10-19\n", | |
"OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.18.04)\n", | |
"OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.18.04, mixed mode, sharing)\n" | |
] | |
} | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"source": [ | |
"Reload the page with cmd/ctrl+r, it should connect to the kotlin runtime, then run the below cell. " | |
], | |
"metadata": { | |
"id": "PvEaKj-BSwWl" | |
} | |
}, | |
{ | |
"cell_type": "code", | |
"source": [ | |
"data class Data(val content: String)\n", | |
"Data(\"content\")\n", | |
" .also(::println)" | |
], | |
"metadata": { | |
"id": "Ysmv3i0uTQAy" | |
}, | |
"execution_count": null, | |
"outputs": [] | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment