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: Torsten Wagner
Subject: Re: [O] How-to evaluate Java-snippets in org-mode/org-babel?
Date: Thu, 28 Jul 2011 19:49:12 +0900
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:5.0) Gecko/20110628 Thunderbird/5.0

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?!

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.

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



Attachment: java_classpath.patch
Description: Text Data


reply via email to

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