Skip to content

Commit 62f5e22

Browse files
committed
Dynamically change the kernel startup parameters #12
1 parent 6e537d1 commit 62f5e22

File tree

2 files changed

+11
-27
lines changed

2 files changed

+11
-27
lines changed

README.md

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,14 @@ Configuring the kernel can be done via environment variables. These can be set o
107107

108108
#### List of options
109109

110-
| Environment variable | Parameter name | Default | Description |
111-
|----------------------|----------------|---------|-------------|
112-
| `JJAVA_COMPILER_OPTS` | `comp-opts` | `""` | A space delimited list of command line options that would be passed to the `javac` command when compiling a project. For example `-parameters` to enable retaining parameter names for reflection. |
113-
| `JJAVA_TIMEOUT` | `timeout` | `"-1"` | A duration specifying a timeout (in milliseconds by default) for a _single top level statement_. If less than `1` then there is no timeout. If desired a time may be specified with a [`TimeUnit`](https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/TimeUnit.html) may be given following the duration number (ex `"30 SECONDS"`). |
114-
| `JJAVA_CLASSPATH` | `classpath` | `""` | A file path separator delimited list of classpath entries that should be available to the user code. **Important:** no matter what OS, this should use forward slash "/" as the file separator. Also each path may actually be a [simple glob](#simple-glob-syntax). |
110+
| Environment variable | Parameter name | Default | Description |
111+
|------------------------------|------------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
112+
| `JJAVA_COMPILER_OPTS` | `comp-opts` | `""` | A space delimited list of command line options that would be passed to the `javac` command when compiling a project. For example `-parameters` to enable retaining parameter names for reflection. |
113+
| `JJAVA_TIMEOUT` | `timeout` | `"-1"` | A duration specifying a timeout (in milliseconds by default) for a _single top level statement_. If less than `1` then there is no timeout. If desired a time may be specified with a [`TimeUnit`](https://docs.oracle.com/javase/9/docs/api/java/util/concurrent/TimeUnit.html) may be given following the duration number (ex `"30 SECONDS"`). |
114+
| `JJAVA_CLASSPATH` | `classpath` | `""` | A file path separator delimited list of classpath entries that should be available to the user code. **Important:** no matter what OS, this should use forward slash "/" as the file separator. Also each path may actually be a [simple glob](#simple-glob-syntax). |
115115
| `JJAVA_STARTUP_SCRIPTS_PATH` | `startup-scripts-path` | `""` | A file path seperator delimited list of `.jshell` scripts to run on startup. This includes [jjava-jshell-init.jshell](src/main/resources/jjava-jshell-init.jshell) and [jjava-display-init.jshell](src/main/resources/jjava-display-init.jshell). **Important:** no matter what OS, this should use forward slash "/" as the file separator. Also each path may actually be a [simple glob](#simple-glob-syntax). |
116-
| `JJAVA_STARTUP_SCRIPT` | `startup-script` | `""` | A block of java code to run when the kernel starts up. This may be something like `import my.utils;` to setup some default imports or even `void sleep(long time) { try {Thread.sleep(time); } catch (InterruptedException e) { throw new RuntimeException(e); }}` to declare a default utility method to use in the notebook. |
116+
| `JJAVA_STARTUP_SCRIPT` | `startup-script` | `""` | A block of java code to run when the kernel starts up. This may be something like `import my.utils;` to setup some default imports or even `void sleep(long time) { try {Thread.sleep(time); } catch (InterruptedException e) { throw new RuntimeException(e); }}` to declare a default utility method to use in the notebook. |
117+
| `JJAVA_JVM_OPTS` | - | `""` | A space delimited list of command line options that would be passed to the `java` command running the kernel. **NOTE** this is a runtime only option, and have no corresponding install parameter |
117118

118119
##### Simple glob syntax
119120

@@ -133,29 +134,11 @@ See the [List of options](#list-of-options) section for all of the configuration
133134
134135
To change compiler options use the `JJAVA_COMPILER_OPTS` environment variable (or `--comp-opts` parameter during installation) with a string of flags as if running the `javac` command.
135136
136-
The kernel VM parameters must currently be assigned in the `kernel.json` by adding/editing a JSON dictionary at the `env` key and changing the `argv` list. To find where the kernel is installed run
137+
To change JVM parameters use the `JJAVA_JVM_OPTS` environment variable with a string of flags as if running the `java` command.
138+
For example to enable assertions and set a limit on the heap size to `128m`:
137139
138140
```bash
139-
> jupyter kernelspec list
140-
Available kernels:
141-
java .../kernels/java
142-
python3 .../python35/share/jupyter/kernels/python3
143-
```
144-
145-
and the `kernel.json` file will be in the given directory.
146-
147-
For example to enable assertions, set a limit on the heap size to `128m`.
148-
149-
```diff
150-
{
151-
- "argv": [ "java", "-jar", "{connection_file}"],
152-
+ "argv": [ "java", "-ea", "-Xmx128m", "-jar", "{connection_file}"],
153-
"display_name": "Java",
154-
"language": "java",
155-
"interrupt_mode": "message",
156-
"env": {
157-
}
158-
}
141+
set JJ_JVM_OPTS=-ea -Xmx128m
159142
```
160143
161144
[//]: # ( "-agentlib:jdwp=transport=dt_socket,server=y,address=5005,suspend=n",)

RELEASE-NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- #7 Project renaming
55
- #8 Java package change
66
- #11 Enable GitHub Actions
7+
- #12 Dynamically change the kernel startup parameters
78
- #16 Upgrade gson transitive dependency
89
- #21 Rendering stale var
910

0 commit comments

Comments
 (0)