I've been having trouble setting up ditaa to work in emacs, I got my copy of the ditaa jar from here And I've been trying to run this code block

#+begin_src ditaa :file hello.png :exports results 
  | Hello World!!! |
  |                |


When I evaluate it with C-c C-c I get A blank png buffer and this:

 Error: Unable to access jarfile /home/nalis/emacs-custom-packages/ditaa/ditaa.jar

in a buffer called Shell Command Output

I've tried moving the jar files to shorter names, putting their location in my system path, and running ditaa outside of emacs to my success.

My Current configurations for my org group are:

Org Ditaa Jar Path: ~/emacs-custom-packages/ditaa/ditaa.jar
Org Babel Ditaa Java Cmd: java
Org Ditaa Jar Option: -jar

And I am running: GNU Emacs 24.5.1 (x86_64-unknown-cygwin, GTK+ Version 3.14.13) of 2015-06-23 on desktop-new

  • 1
    Since this is on Windows, I think I remember there was an issue with "trusting" files that were downloaded from the internet. Could it possibly be something like that? I think that in the file properties (something that should be accessible from the context menu in explorer) on the first tab it'd say something about downloading files from the internet and have a checkbox you need to tick / untick. Also, is this Java installed through Cigwin, or is this a Windows Java? If it is the later, did you try giving it the Windows-y path instead?
    – wvxvw
    Mar 4, 2016 at 9:20
  • I had @melioratus take a look at it, and he said something along those lines about it being a permissions problem. As for my java installation it was done in windows, and the windows-y paths all net the same problem. But I'll take a look at the jar files themselves.
    – Nalisarc
    Mar 5, 2016 at 1:04
  • @wvxvw You're right! I had to unblock them in properties, now I can call them as long as I am above the jar files in cmd and minty, so that's part of the problem thanks!
    – Nalisarc
    Mar 5, 2016 at 1:18
  • Cool, glad I could help.
    – wvxvw
    Mar 5, 2016 at 9:38

5 Answers 5


Try this

  1. Find full directory path where emacs expects ditaa.jar to be located.

    This code is copied from ob-ditaa.el

    #+begin_src elisp
                         (file-name-directory (org-find-library-dir "org")))))))

    Note: This path in your setup may be different, so you should run the code above to check then adjust the instructions to meet your specific path.

    : /usr/share/emacs/24.5/lisp/contrib/scripts/ditaa.jar
  2. Copy ditaa.jar and DitaaEps.jar into expected directory, e.g. /usr/share/emacs/24.5/lisp/contrib/scripts

  3. Windows specific step - Confirm that ditaa.jar and DitaaEps.jar are unblocked otherwise Windows OS will block execution.

  4. Cygwin specific step - Create call-ditaa.sh wrapper script.

    Note: The Oracle JSE for Windows expects Windows paths not Cygwin paths, so we needed to convert using cygpath command.

    #+begin_src sh :tangle yes :shebang #!/usr/bin/env bash
        # Convert to windows file paths.
        java $1 $2 "$(cygpath -w $3)" "$(cygpath -w $4)" "$(cygpath -w $5)"
  5. Cygwin specific Step - Customize org-mode to use wrapper script instead calling java directly.

    Note: I suggest putting call-ditaa.sh script in same directory as ditaa.jar.

    Org Babel Ditaa Java Cmd: /usr/share/emacs/24.5/lisp/contrib/scripts/call-ditaa.sh
  6. Customize org-mode to Org Ditaa Jar Path to expected path, e.g. /usr/share/emacs/24.5/lisp/contrib/scripts/ditaa.jar

  7. Apply & Save customization

  8. Test Updated ditaa Settings

    #+begin_src ditaa :file ./helloworld.png
    | Hello World!!! |
    |                |
  • When I save in org-mode, it removes the trailing whitespace off each line. This breaks my diagram. any ideas on how one might mitigate that issue? Jan 9, 2022 at 13:12
  • Thank you for your suggestion. It works on my cygwin system -- mostly. The problem is that when I call ditaa with :cmdline options, they get mixed in after $3 but before the last two. Am working on modifying your script to take that possibility into account. Dec 29, 2023 at 0:00

I am afraid that moving files manually will mess up my system, confuse my package manager and only work until the next update. Instead, you can simply added the true path for ditaa.jar to your .emacs or .emacs.d/init.el. In my case:

(setq org-ditaa-jar-path "/usr/share/ditaa/lib/ditaa.jar")
  • 3
    I can't speak for a windows setup but this is definitely the better answer on Linux.
    – Chris
    Feb 7, 2022 at 22:40
  • ... or using describe-variable org-ditaa-jar-path, updating and saving it. May 29, 2022 at 11:24

Base on Melioratus answer I did this:

 cd .emacs.d/elpa && mkdir contrib
 cd contrib %% mkdir scripts
 cd scripts
 which ditaa   ## I have mine in /usr/local/bin
 ln -s /usr/local/bin/ditaa0_9.jar ditaa.jar
 ln -s /usr/local/bin/DitaaEps.jar DitaaEps.jar

Now emacs/ org-babel can find ditaa, success!


I've tried moving the jar files to ... my system path

try lib path instead, or run this command at a terminal prompt to see if ditaa runs on your system without errors:

java -jar ditaaXXX.jar

adjust the path to the jar file, where xxx is the version number. If installed properly, you'd get the help screen for command line options.

  • Okay, I moved ditaa.jar to my /lib/ directory, and renamed it ditaa0_9.jar when I call it in bash I get the same error, but when I use cd to move to lib then it works.
    – Nalisarc
    Mar 4, 2016 at 1:55
  • try fixing lib path to properly recognize that /dir/
    – Emacs User
    Mar 4, 2016 at 2:37

Adding on to @Melioratus's excellent and comprehensive answer: there remains a problem on my cygwin system when I call ditaa with command line options, as in:

#+begin_src ditaa :file images/test_ditaa.png :cmdline -r -s 1.2

In that case, when I replace the body of call-ditaa.sh with

while [ $i -le $j ] 
    echo "$i: $1";
    i=$((i + 1));
    shift 1;

I get *Shell Command Output*

1: -Dfile.encoding=UTF-8
2: -jar
3: /usr/local/share/ditaa/lib/ditaa.jar
4: -r
5: -s
6: 1.2
7: /cygdrive/c/Users/me/AppData/Local/Temp/babel-QIscl8/ditaa-xxpRQl
8: /cygdrive/c/Users/me/Downloads/images/test_ditaa.png

The extra command line options have wedged themselves inconveniently in the middle of the command line.

Here is my modified call-ditaa.sh script. It edits the command line in two steps, once for the third argument and once for the last two, then calls java. It seems to work well for me.

set -- "${@:1:2}" "$(cygpath -w $3)" "${@:4}"
set -- "${@: 1:$#-2}" "$(cygpath -w ${@: -2:1})" "$(cygpath -w ${@: -1:1})"
java "$@"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.