joethei / obsidian-plantuml

Generate PlantUML Diagrams inside Obsidian.md
MIT License
368 stars 18 forks source link

Generating PlantUML diagram/Unable to locate a Java Runtime #26

Closed dev-zero closed 2 years ago

dev-zero commented 2 years ago

Is your feature request related to a problem? Please describe.

When trying to use the plugin with a local JAR on macOS, I get only Generating PlantUML diagram while in the console I see:

VM659:5157 Uncaught (in promise) Error: The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

    at ChildProcess.eval (eval at <anonymous> (app.js:1:1494667), <anonymous>:5157:20)
    at ChildProcess.emit (node:events:402:35)
    at maybeClose (node:internal/child_process:1064:16)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)

Removing the path to the JAR (/usr/local/Cellar/plantuml/1.2022.4/libexec/plantuml.jar) makes it work.

Describe the solution you'd like

Being able to specify a JAR and have it working.

Describe alternatives you've considered

I tried to figure out how to add the path to the java executable manually, but couldn't figure out where. which java gives me /usr/bin/java, inspecting the plantuml wrapper installed by Homebrew as shown below gives a different path to the java runtime.

#!/bin/bash
if [[ "$*" != *"-gui"* ]]; then
  VMARGS="-Djava.awt.headless=true"
fi
GRAPHVIZ_DOT="/usr/local/opt/graphviz/bin/dot" exec "/usr/local/opt/openjdk/bin/java" $VMARGS -jar /usr/local/Cellar/plantuml/1.2022.4/libexec/plantuml.jar "$@"

Additional context

dev-zero commented 2 years ago

Changing the java executable from java to /usr/local/opt/openjdk/bin/java leads to a different error:

VM187:5099 Uncaught (in promise) Error: child exited with code 127
    at ChildProcess.eval (eval at <anonymous> (app.js:1:1494667), <anonymous>:5099:20)
    at ChildProcess.emit (node:events:402:35)
    at maybeClose (node:internal/child_process:1064:16)
    at Socket.<anonymous> (node:internal/child_process:450:11)
    at Socket.emit (node:events:390:28)
    at Pipe.<anonymous> (node:net:687:12)
dev-zero commented 2 years ago

as a side note and maybe worth a separate issue: the Default processor for includes does not seem to persist here. Whenever I return to the settings form it is on PNG again.

joethei commented 2 years ago

I published an update that adds a setting to configure the path to the java executable.

The Default processor for includes setting will also show the saved value now(It was saved properly before, but not displayed.)

dev-zero commented 2 years ago

Awesome, works, thanks a lot!