From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id CENpI/k3j1/QLQAA0tVLHw (envelope-from ) for ; Tue, 20 Oct 2020 19:18:17 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id yElRH/k3j1/mTwAA1q6Kng (envelope-from ) for ; Tue, 20 Oct 2020 19:18:17 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C96B294023C for ; Tue, 20 Oct 2020 19:18:16 +0000 (UTC) Received: from localhost ([::1]:59912 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUx9B-0007r5-0Y for larch@yhetil.org; Tue, 20 Oct 2020 15:18:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37380) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUx8A-0007qi-KX for emacs-orgmode@gnu.org; Tue, 20 Oct 2020 15:17:10 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:38591) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kUx88-0006rZ-BD for emacs-orgmode@gnu.org; Tue, 20 Oct 2020 15:17:10 -0400 Received: by mail-wr1-x443.google.com with SMTP id n18so3658261wrs.5 for ; Tue, 20 Oct 2020 12:17:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:message-id :date:mime-version; bh=tVy3wu3Ov6P11h7xei6YeK0zy+Kvd2GWCCD+MtyrLkA=; b=W+ifYNOYtJAtIhrDT2KyJKKqIIkV2NGOCtT2cZxdWlBcc/ZcvYB81cbFmUHPmK7QZx hjrxEvNfDtVedirY5Ark0A0NZA1CTfkfG/e+nFVNZQMFD06TyECkMysdXKNV7fnPA+vH yEFFA6RyXNTik62hAvYTFoBAcrMs/e5m2x94IH4tg2GCRpUncwuSfcLe3sNRerro6Nx6 pQ5qhN5vTZLmjBJyvh2CNbvWtSmeU2wq3DLQasoXZpjLh1aM1n2RKIfZ2FeZ/gFjJTAu o2dp5sTlkcvVVXGg2v03L8vSIk67tBVqlgb77JypKv7DOpEKGdyapUN4zCOIlKQNSOo+ q3wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:message-id:date:mime-version; bh=tVy3wu3Ov6P11h7xei6YeK0zy+Kvd2GWCCD+MtyrLkA=; b=F0uxwnPv+eIr6+dPDeC08BqxthYWaVnH9S73tDrdle0KeTUcAtwSqkT4f3sRf8+hSH OQk47kcnNw0ZlQ8cq2GcsZbFM4PCfEkiAmWaPLZTPvgLLpNICv98Osa9Cuxa7t9Za1q1 QJ9jptIiy44SrHmO7mEZqY8h61S1NUVus1pYiO4PbKLiLyl++s5b25tDxBOkB1qPggwA czvICpeMb8YGkwEYeNJjmbyzonaoLREtNawnXotpDL3mDYOnYjJ92ZMkefHwfhZ8RFKu LgcBOXuetKIgn0x0iiIGPjBxs4AQVp4VAL3gO774QvhuwiEZCq5+NsJaCnEosuHu6fJQ 8/Uw== X-Gm-Message-State: AOAM5332lElhXTOsgaz7ruIbbnwhm673ZNlkiCZi799o/PeDCm4dKud1 +/27vvgqUmbG8YHxZF+wgRtyx4QyXnQ= X-Google-Smtp-Source: ABdhPJxFdLQBEY5qC0YZYET+52wUGpDun4KEWxnGlwh2jffGQXvlEliXooSCpm3WPrQtjUpbCc2RJA== X-Received: by 2002:a1c:9e0e:: with SMTP id h14mr4361419wme.18.1603221426040; Tue, 20 Oct 2020 12:17:06 -0700 (PDT) Received: from fnox (h-160-111.A147.priv.bahnhof.se. [85.24.160.111]) by smtp.gmail.com with ESMTPSA id n62sm3626773wmb.10.2020.10.20.12.17.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 12:17:05 -0700 (PDT) References: User-agent: mu4e 1.4.13; emacs 27.1 From: John Herrlin To: ian martins Subject: Re: [PATCH] ob-java In-reply-to: Message-ID: <87h7qohfm8.fsf@gmail.com> Date: Tue, 20 Oct 2020 21:17:03 +0200 MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=jherrlin@gmail.com; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=W+ifYNOY; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.71 X-TUID: mjCVJZRM+Y1T Hey, Did some debugging and found out that my class didn't contained =public= and the patch requires it to be. This works fine: #+HEADER: :classname Main #+HEADER: :dir src #+HEADER: :cmdline -classpath ./rxjava-1.3.8.jar:. #+HEADER: :cmpflag -classpath ./rxjava-1.3.8.jar #+BEGIN_SRC java :results output code import rx.Observable; public class Main { public static void main(String[] args) { Observable.range(5, 5) .subscribe(System.out::println); } } #+END_SRC ian martins writes: > I noticed that the tests didn't run with "make test." This updates the > patch so that they can. I didn't add java to the list of default languages > because the java tests are slow. > > On Mon, Oct 5, 2020 at 9:23 AM ian martins wrote: > >> I wrote those examples in an org file so I could test as I wrote them, and >> then exported it to make it more readable, but the export resulted in >> source block headers being lost. Here is the same without export: >> ---- >> * Changes >> >> - support for functional mode (~:results value~) >> - accept variables >> - don't require package, class, and main definitions >> - write source and result tempfiles to ~org-babel-temporary-directory~, >> but respects the ~:dir~ header >> - work with tramp >> >> * Examples >> ** Example 1 >> This outputs "hello." If class and main definitions aren't given the >> code block will be wrapped in generic ones. >> >> #+begin_src java :results output silent >> System.out.print("hello"); >> #+end_src >> >> This is exactly equivalent: >> >> #+begin_src java :results output silent >> public class Main { >> public static void main(String[] args) { >> System.out.print("hello"); >> } >> } >> #+end_src >> >> ** Example 2 >> This also outputs "hello." >> >> #+begin_src java :results value silent >> return "hello"; >> #+end_src >> >> ** Example 3 >> This generates the class "Example" in the package "org.orgmode" in the >> current directory. >> >> #+begin_src java :results output silent :classname org.orgmode.Example >> :dir . >> System.out.print("hello, org-mode"); >> #+end_src >> >> ** Example 4 >> The "Hey" class defines a static method but no main. C-c C-c on the >> "Hey" source block will write "./org/orgmode/Hey.java" and compile it. >> >> The "Main" class calls the "Hey" class. C-c C-c on the "Main" source >> block will write "./org/orgmode/Main.java" and compile and run it. >> >> #+begin_src java :results output silent :dir . >> package org.orgmode; >> >> public class Hey { >> public static String say() { >> return "hey"; >> } >> } >> #+end_src >> >> #+begin_src java :results output silent :dir . >> package org.orgmode; >> >> public class Main { >> public static void main(String[] args) { >> System.out.print(Hey.say()); >> } >> } >> #+end_src >> >> Instead of C-c C-c, we could have added tangle headers and written the >> source files out by tangling. >> >> ** Example 5 >> This prints the variable from the header >> >> #+begin_src java :var msg="hello, org-mode" :results output silent >> System.out.print(msg); >> #+end_src >> >> ** Example 6 >> This prints "hello, org-mode." The table is provided to the method as a >> list of lists. >> >> #+name: table >> | message | hello, org-mode | >> >> #+begin_src java :var tbl=table :results output silent >> System.out.print(tbl.get(0).get(1)); >> #+end_src >> >> ** Example 7 >> This example returns a list. >> >> Note that you're allowed to specify imports without defining the class >> or main methods. >> >> #+begin_src java :results value :exports both >> import java.util.Arrays; >> >> return Arrays.asList("message", "hello, org-mode"); >> #+end_src >> >> #+RESULTS: >> | message | hello, org-mode | >> >> On Mon, Oct 5, 2020 at 8:35 AM ian martins wrote: >> >>> 1 Changes >>> ========= >>> >>> - support for functional mode (`:results value') >>> - accept variables >>> - don't require package, class, and main definitions >>> - write source and result tempfiles to >>> `org-babel-temporary-directory', but respects the `:dir' header >>> - work with tramp >>> >>> >>> 2 Examples >>> ========== >>> Some examples follow. See the tests for more examples. I'll write >>> proper docs after review. >>> >>> 2.1 Example 1 >>> ~~~~~~~~~~~~~ >>> >>> This outputs "hello." If class and main definitions aren't given the >>> code block will be wrapped in generic ones. >>> >>> ,---- >>> | System.out.print("hello"); >>> `---- >>> >>> This is exactly equivalent: >>> >>> ,---- >>> | public class Main { >>> | public static void main(String[] args) { >>> | System.out.print("hello"); >>> | } >>> | } >>> `---- >>> >>> >>> 2.2 Example 2 >>> ~~~~~~~~~~~~~ >>> >>> This also outputs "hello." >>> >>> ,---- >>> | return "hello"; >>> `---- >>> >>> >>> 2.3 Example 3 >>> ~~~~~~~~~~~~~ >>> >>> This generates the class "Example" in the package "org.orgmode" in the >>> current directory. >>> >>> ,---- >>> | System.out.print("hello, org-mode"); >>> `---- >>> >>> >>> 2.4 Example 4 >>> ~~~~~~~~~~~~~ >>> >>> The "Hey" class defines a static method but no main. C-c C-c on the >>> "Hey" source block will write "./org/orgmode/Hey.java" and compile it. >>> >>> The "Main" class calls the "Hey" class. C-c C-c on the "Main" source >>> block will write "./org/orgmode/Main.java" and compile and run it. >>> >>> ,---- >>> | package org.orgmode; >>> | >>> | public class Hey { >>> | public static String say() { >>> | return "hey"; >>> | } >>> | } >>> `---- >>> >>> ,---- >>> | package org.orgmode; >>> | >>> | public class Main { >>> | public static void main(String[] args) { >>> | System.out.print(Hey.say()); >>> | } >>> | } >>> `---- >>> >>> Instead of C-c C-c, we could have added tangle headers and written the >>> source files out by tangling. >>> >>> >>> 2.5 Example 5 >>> ~~~~~~~~~~~~~ >>> >>> This prints the variable from the header >>> >>> ,---- >>> | System.out.print(msg); >>> `---- >>> >>> >>> 2.6 Example 6 >>> ~~~~~~~~~~~~~ >>> >>> This prints "hello, org-mode." The table is provided to the method as >>> a list of lists. >>> >>> message hello, org-mode >>> >>> ,---- >>> | System.out.print(tbl.get(0).get(1)); >>> `---- >>> >>> >>> 2.7 Example 7 >>> ~~~~~~~~~~~~~ >>> >>> This example returns a list. >>> >>> Note that you're allowed to specify imports without defining the class >>> or main methods. >>> >>> ,---- >>> | import java.util.Arrays; >>> | >>> | return Arrays.asList("message", "hello, org-mode"); >>> `---- >>> >>> message hello, org-mode >>> >>