padreati / rapaio-jupyter-kernel

Java jupyter kernel
MIT License
53 stars 7 forks source link

Is it possible to specify the JDK ? #68

Closed bsorrentino closed 2 months ago

bsorrentino commented 2 months ago

I'm using this very promising java Jupyter kernel, my problem is that I've installed on my workstation multiple JDK (using jenv) and I would want to know if there are a way to configure a default JDK for it

dsyer commented 2 months ago

You can edit the kernel.json to link to a specific JDK. E.g. I am using this via jbang:

{
  "argv" : [
    "/home/dsyer/.sdkman/candidates/jbang/current/bin/jbang",
    "--java",
    "22",
    "--ea",
    "-R--add-modules",
    "-Rjava.base,jdk.incubator.vector",
    "-R-ea",
    "-R--add-opens",
    "-Rjava.base/jdk.internal.misc=ALL-UNNAMED",
    "-R--illegal-access=permit",
    "io.github.padreati:rapaio-jupyter-kernel:2.1.0@fatjar",
    "{connection_file}"
  ],
  "display_name" : "java (Rapaio/j!)",
  "language" : "java",
  "interrupt_mode" : "message",
  "env" : {
    "RJK_TIMEOUT_MILLIS" : "-1",
    "RJK_COMPILER_OPTIONS" : ""
  }
}

but you can put a java executable in the "argv" as well, e.g:

{
  "argv": [
    "/home/dsyer/.sdkman/candidates/java/current/bin/java",
    "--enable-preview",
    "--add-modules",
    "java.base,jdk.incubator.vector",
    "-jar",
    "/home/dsyer/.local/share/jupyter/kernels/rapaio/rapaio-jupyter-kernel-2.1.0.jar",
    "{connection_file}"
  ],
  "display_name": "Java (rjk 2.1.0)",
  "language": "java",
  "interrupt_mode": "message",
  "env": {
    "RJK_COMPILER_OPTIONS": "",
    "RJK_INIT_SCRIPT": "",
    "RJK_TIMEOUT_MILLIS": "360000"
  }
}