6

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!!! |
  |                |
  +----------------+

#+end_src

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 '16 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 '16 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 '16 at 1:18
  • Cool, glad I could help. – wvxvw Mar 5 '16 at 9:38
2

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
    (expand-file-name
                 "ditaa.jar"
          (file-name-as-directory
                (expand-file-name
                    "scripts"
                   (file-name-as-directory
                      (expand-file-name
                          "../contrib"
                         (file-name-directory (org-find-library-dir "org")))))))
    #+end_src
    

    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.

    #+RESULTS:
    : /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)"
    
    
    #+end_src
    
  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!!! |
    |                |
    +----------------+
    #+end_src
    
    #+RESULTS:
    [[file:./helloworld.png]]
    
1

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!

0

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 '16 at 1:55
  • try fixing lib path to properly recognize that /dir/ – Emacs User Mar 4 '16 at 2:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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