From: Eric Schulte <schulte.eric@gmail.com>
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: Thu, 28 Jul 2011 18:06:06 -0600 [thread overview]
Message-ID: <87vcumc5j9.fsf@gmail.com> (raw)
In-Reply-To: 4E313EA8.3010008@gmail.com
Torsten Wagner <torsten.wagner@gmail.com> writes:
> Hi Eric,
>
> some feedback of first testing weeks....
> It works well on my desktop machine, I tried to do the same on my
> laptop. However, I faced the problem that java did not find the files.
> I tried everything. Made sure using the same java and emacs version
> (same linux distro, same test file). Copied over .emacs config files,
> compared the versions of ob-java.el on both machines. I couldn't
> figure out why it works with one and does not work on the other
> machine.
> Somehow the classpath seems to differ buy I do not see where to change
> it in the correct way.
>
> I hacked a bit into ob-java.el file. I noticed that you call the
> generated class file by creating the string
>
> java packagename/classname
>
> whereas packagename/classname is coming from the classname variable
> set at the source-code block.
>
> In the earlier attempt we used
>
> java -cp . packagename.classname
>
> which makes sure the classpath is set to the local directory.
>
> I hacked this into your code and now it works on the laptop too (to
> say this modification works on both desktop and laptop). It might be
> worse to add, since the classpath seems to be set depending on many
> parameters (distro, other java ides, local user settings, etc.). Thus,
> many might observe problems at this point.
>
> Please find a patch attached.
>
> Even better would be to add an option to set the classpath but my
> elisp skills are to poor for that.... but would like to see how to do
> it ;)
> #+BABEL: :classpath "."
> where it might be the local directory by default?!
>
I've just pushed up a slightly different solution which involves two new
header arguments
- :cmpflag can be used to pass flags to the java compiler (e.g., "cp .")
- :cmdline can be used to pass flags to the java executable (e.g., "cp .")
So, the following could be used to get the behavior resulting from your
patch using these flags.
#+begin_src emacs-lisp
(setq org-babel-default-header-args:java '((:cmpflag "-cp .") (:cmdline "-cp .")))
#+end_src
This solution somehow seems more flexible in that it won't force a
classpath value on users and will allow for passing other flags to the
java runtime.
>
> Beside of that I noticed that there might be a need for a plain-text
> mode.. sounds funny, but maybe sometimes someone need auxiliary files
> which are not executed by themselves. Sure I could use simply a shell
> session and echo into a file, or tangle it, but I guess it might be
> more elegant to have a, "only-paste-this-into-this-file-execute"
>
> #+BEGIN_SRC: plain :filename folder/folder/testdata.csv
> 1, 2
> 2, 4
> 3, 8
> #+END_SRC
> to generate /folder/folder/testdata.csv which contains the data in the
> block.
>
This is currently possible with tangling, e.g.,
#+begin_src text :tangle somewhere.txt
This will still tangle out to a file, and it opens in text mode, which
may be nice.
#+end_src
Thanks for the feedback and the patch -- Eric
>
> Because sometimes, one might need to call external programs or
> programs in code-blocks are supposed to read data from files instead
> from within org-babel.
>
> In general this could be the standard feature for all unrecognised
> languages. Probably with a warning that the required
> compiler/interpreter is not configured. However, this would allow
> people at least to get the source files which they could use
> externally. The difference to tangle would be that one can decide
> block by block what to execute. E.g., I could have several of the
> above "testdata" blocks and simply executing one of them would change
> the input for later code blocks.
>
> Totti
>
>
>
>
--
Eric Schulte
http://cs.unm.edu/~eschulte/
prev parent reply other threads:[~2011-07-29 0:08 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
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 [this message]
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=87vcumc5j9.fsf@gmail.com \
--to=schulte.eric@gmail.com \
--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).