almond-sh / almond

A Scala kernel for Jupyter
https://almond.sh
BSD 3-Clause "New" or "Revised" License
1.59k stars 239 forks source link

Add extra Java Options to Scala kernel #1397

Open emlynazuma opened 1 month ago

emlynazuma commented 1 month ago

Hi, I wonder if I could add extra Java options to kernel.json. For my use case, I just need to add an --add-opens... argument during the kernel start.

❯ coursier bootstrap almond:0.13.14 --scala 2.12 --output almond --force
❯ ./almond --install --global --force
Installed scala kernel under /usr/local/share/jupyter/kernels/scala
❯ cat /usr/local/share/jupyter/kernels/scala/kernel.json
{
  "argv": [
    "java",
    "--add-exports=java.base/sun.nio.ch=ALL-UNNAMED",   # how can I add this line?
    "-jar",
    "/usr/local/share/jupyter/kernels/scala/launcher.jar",
    "--connection-file",
    "{connection_file}"
  ],
  "display_name": "Scala",
  "language": "scala"
}%

It seems there are directives to add Java options. However, It is unclear how to utilize these directives, e.g. where to put these directives code? how to execute them?

//> using javaOpt "-Xmx10g"
//> using javaOpt "-Dfoo=bar"

For now, I have to write a script to post-modify kernel.json after almond has installed the kernel. It will be great if I can achieve it during almond install stage.

tongwaiazuma commented 1 month ago

After switching to sh.almond::launcher:0.14.0-RC15, I found that there is a --java-opts to fulfill my need. Thanks very much!