1 Changes
=========
- support for functional mode (`:results value')
- accept variables
- don't require package, class, and main definitions
- write source and result tempfiles to
`org-babel-temporary-directory', but respects the `:dir' header
- work with tramp
2 Examples
==========
Some examples follow. See the tests for more examples. I'll write proper docs after review.
2.1 Example 1
~~~~~~~~~~~~~
This outputs "hello." If class and main definitions aren't given the
code block will be wrapped in generic ones.
,----
| System.out.print("hello");
`----
This is exactly equivalent:
,----
| public class Main {
| public static void main(String[] args) {
| System.out.print("hello");
| }
| }
`----
2.2 Example 2
~~~~~~~~~~~~~
This also outputs "hello."
,----
| return "hello";
`----
2.3 Example 3
~~~~~~~~~~~~~
This generates the class "Example" in the package "org.orgmode" in the
current directory.
,----
| System.out.print("hello, org-mode");
`----
2.4 Example 4
~~~~~~~~~~~~~
The "Hey" class defines a static method but no main. C-c C-c on the
"Hey" source block will write "./org/orgmode/Hey.java" and compile it.
The "Main" class calls the "Hey" class. C-c C-c on the "Main" source
block will write "./org/orgmode/Main.java" and compile and run it.
,----
| package org.orgmode;
|
| public class Hey {
| public static String say() {
| return "hey";
| }
| }
`----
,----
| package org.orgmode;
|
| public class Main {
| public static void main(String[] args) {
| System.out.print(Hey.say());
| }
| }
`----
Instead of C-c C-c, we could have added tangle headers and written the
source files out by tangling.
2.5 Example 5
~~~~~~~~~~~~~
This prints the variable from the header
,----
| System.out.print(msg);
`----
2.6 Example 6
~~~~~~~~~~~~~
This prints "hello, org-mode." The table is provided to the method as
a list of lists.
message hello, org-mode
,----
| System.out.print(tbl.get(0).get(1));
`----
2.7 Example 7
~~~~~~~~~~~~~
This example returns a list.
Note that you're allowed to specify imports without defining the class
or main methods.
,----
| import java.util.Arrays;
|
| return Arrays.asList("message", "hello, org-mode");
`----
message hello, org-mode