https://github.com/dpressel/simple-kernel-nashorn
A small, simple kernel example for executing Nashorn JavaScript in Jupyter
https://github.com/dpressel/simple-kernel-nashorn
java javascript jupyter jupyter-kernels jupyterlab nashorn
Last synced: 4 months ago
JSON representation
A small, simple kernel example for executing Nashorn JavaScript in Jupyter
- Host: GitHub
- URL: https://github.com/dpressel/simple-kernel-nashorn
- Owner: dpressel
- Created: 2017-03-09T05:24:41.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-11-06T14:34:47.000Z (over 6 years ago)
- Last Synced: 2025-01-03T21:28:14.454Z (6 months ago)
- Topics: java, javascript, jupyter, jupyter-kernels, jupyterlab, nashorn
- Language: Java
- Size: 57.6 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## simple-kernel-nashorn
This builds a JavaScript kernel on top of https://github.com/dpressel/simple-kernel-java (which is a port https://github.com/dsblank/simple_kernel/) using java, jeromq and jackson.
In this version, I extend the simple kernel to do something useful, but still as simply as possible.The changes between this and the simple-kernel-java version are minimal! If you understand the simple kernel, you will probably understand what's happening here too.
Currently the following features are supported
- Execution of any valid Nashorn JavaScript statements
- Serialization of backtrace errors, execution results, and stdout capture back to jupyter lab (or notebook)
- Serializing stdout to the iopub channel is done by changing System.out to temporarily point at ExecutionPrintStream, and then back again after execution
- Pygments JS highlighting
- JavaScript pre-loading of extension librariesA couple of things are yet to be implemented:
- History
- Command completion*Note*: Do not use the Nashorn builtin _print_ function. Use _console.log_ instead!
### Building it
Build the kernel and install it:
```
dpressel@dpressel:~/dev/work/simple-kernel-nashorn$ ./gradlew build && ./gradlew fatJar
:compileJava
Note: /home/dpressel/dev/work/simple-kernel-nashorn/src/main/java/Message.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:processResources UP-TO-DATE
:classes
:jar
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:buildBUILD SUCCESSFUL
Total time: 1.923 secs
:compileJava UP-TO-DATE
:processResources UP-TO-DATE
:classes UP-TO-DATE
:fatJarBUILD SUCCESSFUL
Total time: 2.149 secs
dpressel@dpressel:~/dev/work/simple-kernel-nashorn$ ./install_script.sh
```
### Running it```
dpressel@dpressel:~/dev/work$ jupyter-notebook
```Or
```
dpressel@dpressel:~/dev/work$ jupyter lab```
You should see simple-kernel-nashorn in the list of kernels
### Extending it
The JavaScript can be extended easily. Have a look at extensions.list to see how to add a js library to the Kernel as a pre-defined import.