From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: How-to evaluate Java-snippets in org-mode/org-babel? Date: Thu, 28 Jul 2011 18:06:06 -0600 Message-ID: <87vcumc5j9.fsf@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> <4E313EA8.3010008@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([140.186.70.92]:42272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qmacz-0003gm-4M for emacs-orgmode@gnu.org; Thu, 28 Jul 2011 20:08:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qmacx-0002ZN-4Y for emacs-orgmode@gnu.org; Thu, 28 Jul 2011 20:08:33 -0400 Received: from mail-pz0-f49.google.com ([209.85.210.49]:61195) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qmacw-0002Wc-UX for emacs-orgmode@gnu.org; Thu, 28 Jul 2011 20:08:31 -0400 Received: by mail-pz0-f49.google.com with SMTP id 33so4602614pzk.8 for ; Thu, 28 Jul 2011 17:08:30 -0700 (PDT) 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: Torsten Wagner Cc: Org Mode Mailing List Torsten Wagner 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/