RT,网上有查到运行java但是好象没有jshell的
解决了
#+BEGIN_SRC bash :results verbatim
jshell
int a[] = {0,1,3,5,8}
a
a[3] = 42
a
#+END_SRC
(defun org-babel-execute:jsh (body params)
"Execute a block of jshell code snippets or commands with org-babel"
(message "Executing jshell snippets")
(org-babel-eval "jshell --feedback concise" (concat body "\n/exit")))
(add-to-list 'org-src-lang-modes '("jsh" . "java"))
在有完整功能的 ob-jshell 出来之前将就用一下,比直接扔到 shell 执行好一些,可以执行,也有语法高亮,效果如下。–feedback 如果用 silent 模式会导致 a + b
的结果出不来。
#+begin_src jsh
var a = 1;
var b = 2;
a + b
#+end_src
#+RESULTS:
: jshell> var a = 1;
: jshell> var b = 2;
: jshell> a + b
: $3 ==> 3
: jshell> /exit
参考:https://stackoverflow.com/questions/10405461/org-babel-new-language
1 个赞