emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] How-to evaluate Java-snippets in org-mode/org-babel?


From: Eric S Fraga
Subject: Re: [O] How-to evaluate Java-snippets in org-mode/org-babel?
Date: Tue, 05 Jul 2011 10:07:19 +0100
User-agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux)

Torsten Wagner <address@hidden> writes:

> Hi all,
>
> I need to evaluate many small java snippets. I tried to do this in
> org-mode but so fare it didn't work out. org-babel seems to have no
> java support ?

Not directly but, given the issues with class paths and naming schemes,
I would suggest that the best route is to use babel to tangle code
instead of trying to execute it directly within org.  So, for instance,
you might have:

--8<---------------cut here---------------start------------->8---
#+begin_src java :tangle "mypackage/myclass.java"
package mypackage;
public class myclass
{
   ...
}
#+end_src
--8<---------------cut here---------------end--------------->8---

Then "C-c v t" in org will put the code into the appropriate file.  

You can have different snippets of code (e.g. each individual method in
the class) as separate source code blocks which can be tangled to the
same file.  You can also have different destinations for tangling in the
case that you have different classes.

Finally, you could then have a shell script, within org, to execute the
particular Java class you want:

--8<---------------cut here---------------start------------->8---
#+begin_src sh :results output
javac -cp . mypackage/myclass.java
java -cp . mypackage.myclass
#+end_src
--8<---------------cut here---------------end--------------->8---

Untested but I do this (on Linux, not sure about Windows however) with
Octave all the time, despite Octave being supported by org directly.
When I have multiple functions, this approach is easier.

HTH.
-- 
: Eric S Fraga (GnuPG: 0xC89193D8FFFCF67D) in Emacs 24.0.50.1
: using Org-mode version 7.5 (release_7.5.574.g5a503)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]