'Lunching PlantUML JAR fails via terminal
I downloaded the PlantUML and tryed to run it via Terminal with the command "java -jar /home/Victor/programms/plantUML/plantuml.jar".
But it always throws the following error:
Exception in thread "main" java.awt.HeadlessException at java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:204) at java.awt.Window.(Window.java:536) at java.awt.Frame.(
Frame
.java:420) at javax.swing.JFrame.(JFrame.java:233) at net.sourceforge.plantuml.swing.MainWindow2.(MainWindow2.java:154) at net.sourceforge.plantuml.Run.main(Run.java:131)
The wired things is, when I import the jar to a project into IntelliJ and run it there, it works totally fine. What am I missing, what am I doing wrong. I'm using Fedora (Linux)
Solution 1:[1]
Given the HeadlessException
it appears that your default Java installation is a headless version (i.e. has no support for keyboard, display, etc.); whereas, your IntelliJ installation is using a different Java installation.
Type java -version
to see what information it returns. I'd expect that it might be something to the tune of openjdk-headless
. You may also want to check what other Java installations are available with alternatives --config java
and select a more suitable one, if given.
If alternatives
does not show a full version installation, you can either: 1) add the IntelliJ installation with alternatives set java <path_to_ij_install>
or 2) use yum
to install a full version.
Solution 2:[2]
In my case, I needed to pass '-pipe' option to plantuml as follows when passing text input from stdin:
cat INPUT.txt | java -Djava.io.tmpdir=/var/tmp -Djava.awt.headless=true -jar /PATH/TO/plantuml.jar -pipe ...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Fumisky Wells |