When I run PlantUML without a GUI in as a background process in a shell that doesn't have access to X11, I get this error:
No protocol specified
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0' as the value of the DISPLAY variable.
at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
at sun.awt.X11GraphicsEnvironment.access$200(X11GraphicsEnvironment.java:65)
at sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:110)
at java.security.AccessController.doPrivileged(Native Method)
at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:74)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:190)
at java.awt.GraphicsEnvironment.createGE(GraphicsEnvironment.java:102)
at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:81)
at java.awt.image.BufferedImage.createGraphics(BufferedImage.java:1190)
at net.sourceforge.plantuml.EmptyImageBuilder.<init>(Unknown Source)
at net.sourceforge.plantuml.svek.CucaDiagramFileMakerSvek.<clinit>(Unknown Source)
at net.sourceforge.plantuml.cucadiagram.CucaDiagram.exportDiagramInternal(Unknown Source)
at net.sourceforge.plantuml.UmlDiagram.exportDiagram(Unknown Source)
at net.sourceforge.plantuml.PSystemUtils.exportDiagramsCuca(Unknown Source)
at net.sourceforge.plantuml.PSystemUtils.exportDiagrams(Unknown Source)
at net.sourceforge.plantuml.SourceFileReader.getGeneratedImages(Unknown Source)
at net.sourceforge.plantuml.Run.manageFileInternal(Unknown Source)
at net.sourceforge.plantuml.Run.processArgs(Unknown Source)
at net.sourceforge.plantuml.Run.manageAllFiles(Unknown Source)
at net.sourceforge.plantuml.Run.main(Unknown Source)
A workaround is to run it on a machine with X11 running and have the shell that is starting have access to X11. For example, running it as "su - anotherusername [after logging in] java -jar plantuml.jar test.txt" will give the same error unless you do "xhost +" before. If you run "xhost -" the error will happen again.