Skip to content

Instantly share code, notes, and snippets.

@lukewhitehouse
Last active October 10, 2024 13:05
Show Gist options
  • Save lukewhitehouse/38bbc613082530655eed4dfe4279480b to your computer and use it in GitHub Desktop.
Save lukewhitehouse/38bbc613082530655eed4dfe4279480b to your computer and use it in GitHub Desktop.
How to setup and install PlantUML on Mac OSX and VS Code with Homebrew

How to setup and install PlantUML on Mac OSX and VS Code with Homebrew

Documentation around PlantUML and how to setup (especially when you don't typically work in Java) leave a lot to be desired. Here's a quick run down of how to get plantuml setup and running so you can create, edit, preview and export the diagrams (including C4 Model) in VS Code.

First, ensure you have homebrew installed and updated: https://brew.sh/.

Install the temurin JDK, graphviz and plantuml in that order.

brew install --cask temurin
brew install graphviz
brew install plantuml

Next, install the PlantUML extension for VS Code: https://github.com/qjebbs/vscode-plantuml

You'll want to configure the extension so its using the correct Java binary and PlantUML jar file you just installed. To do this, open up your VS Code settings.json: CMD + SHIFT + P and find "Preferences: Open User Settings (JSON)". Add the following entries to your json object.

"plantuml.java": "/Library/Java/JavaVirtualMachines/temurin-20.jdk/Contents/Home/bin/java",
"plantuml.jar": "/opt/homebrew/Cellar/plantuml/1.2023.7/libexec/plantuml.jar"

Ensure these match the versions you've just installed, version folders may change over time to locate /opt/homebrew/Cellar/plantuml or /Library/Java/JavaVirtualMachines and go from there.

Finally, make sure you do not have the -DRELATIVE_INCLUDE flag included when plantuml runs Java. To check, make sure any of the following is deleted from your VS Code settings.json:

"plantuml.jarArgs": [
   "-DRELATIVE_INCLUDE=."
],
"plantuml.commandArgs": [
  "-DRELATIVE_INCLUDE=."
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment