emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric S Fraga <e.fraga@ucl.ac.uk>
To: Torsten Wagner <torsten.wagner@gmail.com>
Cc: Org Mode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: How-to evaluate Java-snippets in org-mode/org-babel?
Date: Tue, 05 Jul 2011 10:07:19 +0100	[thread overview]
Message-ID: <87tyb1jdtk.fsf@pinto.chemeng.ucl.ac.uk> (raw)
In-Reply-To: <4E12B6DB.4090001@gmail.com> (Torsten Wagner's message of "Tue, 05 Jul 2011 16:01:47 +0900")

Torsten Wagner <torsten.wagner@gmail.com> 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	other threads:[~2011-07-05  9:07 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-05  7:01 How-to evaluate Java-snippets in org-mode/org-babel? Torsten Wagner
2011-07-05  9:07 ` Eric S Fraga [this message]
2011-07-05  9:22   ` Eric S Fraga
2011-07-05 13:48   ` Jason F. McBrayer
2011-07-06 12:36     ` Torsten Wagner
2011-07-06 13:26     ` Eric Schulte
2011-07-06 15:14       ` Jason F. McBrayer
2011-07-06 17:11         ` Torsten Wagner
2011-07-06 19:15         ` Eric S Fraga
2011-07-06 12:28   ` Torsten Wagner
2011-07-06 13:38     ` Eric Schulte
2011-07-14  5:42       ` Torsten Wagner
2011-07-15 15:00         ` Eric Schulte
2011-07-18  1:31           ` Torsten Wagner
2011-07-18 14:53             ` Eric Schulte
2011-07-28 10:49               ` Torsten Wagner
2011-07-29  0:06                 ` Eric Schulte

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tyb1jdtk.fsf@pinto.chemeng.ucl.ac.uk \
    --to=e.fraga@ucl.ac.uk \
    --cc=emacs-orgmode@gnu.org \
    --cc=torsten.wagner@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).