From mboxrd@z Thu Jan 1 00:00:00 1970 From: Torsten Wagner Subject: Re: How-to evaluate Java-snippets in org-mode/org-babel? Date: Thu, 28 Jul 2011 19:49:12 +0900 Message-ID: <4E313EA8.3010008@gmail.com> References: <4E12B6DB.4090001@gmail.com> <87tyb1jdtk.fsf@pinto.chemeng.ucl.ac.uk> <4E145506.70802@gmail.com> <87box75xx6.fsf@gmail.com> <4E1E81AF.4080609@gmail.com> <874o2nlfln.fsf@gmail.com> <87aacba7u4.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------090407000606010006000603" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:36304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QmO9X-0005GQ-GZ for emacs-orgmode@gnu.org; Thu, 28 Jul 2011 06:49:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QmO9W-0002Mt-6J for emacs-orgmode@gnu.org; Thu, 28 Jul 2011 06:49:19 -0400 Received: from mail-yx0-f169.google.com ([209.85.213.169]:36524) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QmO9V-0002Mn-W7 for emacs-orgmode@gnu.org; Thu, 28 Jul 2011 06:49:18 -0400 Received: by yxn22 with SMTP id 22so1666901yxn.0 for ; Thu, 28 Jul 2011 03:49:17 -0700 (PDT) In-Reply-To: <87aacba7u4.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: Org Mode Mailing List This is a multi-part message in MIME format. --------------090407000606010006000603 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------090407000606010006000603 Content-Type: text/x-patch; name="java_classpath.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="java_classpath.patch" >From 9853070846e98c2a14452e51c8756611aa145363 Mon Sep 17 00:00:00 2001 From: Torsten 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 @@ (compile (progn (with-temp-file src-file (insert full-body)) (org-babel-eval - (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))) (org-babel-pick-name (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) -- 1.7.6 --------------090407000606010006000603--