Org-mode allows you to use [Babel](http://orgmode.org/worg/org-contrib/babel/). As it says in the manual: _Babel is Org-mode's ability to execute source code within Org-mode documents_
Here's a bit of Java, wrapped up in Babel
```java
#+BEGIN\_SRC java :classname example
public class example
{
public static void main (String args \[\])
{
System.out.println("Go Babel!");
}
}
#+END\_SRC
```
Put the point in the block and
- **C-c '** to edit the code
- **C-c C-c** to run the code
In the past, I never used Babel as often as I should, mainly because I could never quite remember the syntax.
Then I had the idea of adding Babel to [YASnippet](https://github.com/capitaomorte/yasnippet). I added the following to my org-mode snippets:
```java
# -*- mode: snippet -*-
# name: jbabel
# key: jbabel
# --
#+BEGIN_SRC java :classname $1
public class $1
{
public static void main (String args [])
{
System.out.println("$0");
}
}
#+END_SRC
```
… and now I just have to type jbabel and hit tab to have my Babel block ready to go.
It works with [ditaa](http://ditaa.sourceforge.net/) too. As I could never quite remember all the codes when I needed them, I just put a few of ones I used most frequently in a YASnippet example:
```lisp
# -*- mode: snippet -*-
# name: ditaa babel
# key: dbabel
# --
#+begin_src ditaa :file $1.png
/-----------------\
| Things to do | +-----+
| cGRE | |{s} |
| o Cut the grass \*-+----->| |
| o Buy jam | | |
| o Fix car | +-----+
| o Make website |
\-----------------/
#+end_src
```
And here's what it looks like when converted[](http://tonyballantyne.com/tech/wp-content/uploads/2014/11/dit.png)