emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Torsten Wagner <torsten.wagner@gmail.com>
To: Eric Schulte <schulte.eric@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 19:49:12 +0900	[thread overview]
Message-ID: <4E313EA8.3010008@gmail.com> (raw)
In-Reply-To: <87aacba7u4.fsf@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2671 bytes --]

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
to generate /folder/folder/testdata.csv which contains the data in the 

Because sometimes, one might need to call external programs or programs 
in code-blocks are supposed to read data from files instead from within 

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.


[-- Attachment #2: java_classpath.patch --]
[-- Type: text/x-patch, Size: 1177 bytes --]

From 9853070846e98c2a14452e51c8756611aa145363 Mon Sep 17 00:00:00 2001
From: Torsten <torsten.wagner@gmail.com>
Date: Thu, 28 Jul 2011 19:27:08 +0900
Subject: [PATCH] resolve problems with wrong classpath

 lisp/ob-java.el |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/ob-java.el b/lisp/ob-java.el
index 8595a18..cee797a 100644
--- a/lisp/ob-java.el
+++ b/lisp/ob-java.el
@@ -50,7 +50,7 @@
 	  (progn (with-temp-file src-file (insert full-body))
-		  (concat org-babel-java-compiler " " src-file) ""))))
+		  (concat org-babel-java-compiler " -cp . " src-file) ""))))
     ;; created package-name directories if missing
     (unless (or (not packagename) (file-exists-p packagename))
       (make-directory packagename 'parents))
@@ -65,7 +65,7 @@
 	 (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
 	 (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))
-     (org-babel-eval (concat org-babel-java-command " " classname) ""))))
+     (org-babel-eval (concat org-babel-java-command " -cp . " classname) ""))))
 (provide 'ob-java)

  reply	other threads:[~2011-07-28 10:49 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 [this message]
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:

  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=4E313EA8.3010008@gmail.com \
    --to=torsten.wagner@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=schulte.eric@gmail.com \


* 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


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).