Hello,
I'm using the following code to execute a Lisp function:
#+BEGIN_SRC java
public class Call { public static void main(String [] args) { Call thisObject = new Call(); Interpreter interpreter = Interpreter.createInstance(); interpreter.eval("(load "lispfunctions.lisp")"); org.armedbear.lisp.Package defaultPackage = Packages.findPackage("CL-USER"); Symbol voidsym = defaultPackage.findAccessibleSymbol("SAY-HELLO"); Function voidFunction = (Function) voidsym.getSymbolFunction(); LispObject result = voidFunction.execute(new JavaObject(thisObject)); } }
#+END_SRC
The Lisp side:
#+BEGIN_SRC lisp ;;; lispfunctions.lisp (java:add-to-classpath "/opt/abcl-bin-1.4.0/abcl-contrib.jar")
(require :jss)
(defun say-hello () "Hi!")
#+END_SRC
It works without the (requirese :jss); whenever I try to use it I get:
#<THREAD "main" {C7BBB6C0}>: Debugger invoked on condition of type SIMPLE-ERROR Don't know how to REQUIRE JSS.
Any pointers? Thanks!
You might be missing a: (require "abcl-contrib") line. The following is what works for me. I've got abcl-contrib.jar in the same directory as abcl.jar :
---- ~$ java -jar /usr/local/abcl-bin-1.4.0/abcl.jar Armed Bear Common Lisp 1.4.0 Java 1.8.0_11 Oracle Corporation Java HotSpot(TM) 64-Bit Server VM Low-level initialization completed in 0.392 seconds. Startup completed in 1.994 seconds. Type ":help" for a list of available commands. CL-USER(1): (require "abcl-contrib") Using probed value of abcl-contrib: '/usr/local/abcl-bin-1.4.0/abcl-contrib.jar'. Added jar:file:/usr/local/abcl-bin-1.4.0/abcl-contrib.jar!/quicklisp/ to ASDF. Added jar:file:/usr/local/abcl-bin-1.4.0/abcl-contrib.jar!/mvn/ to ASDF. Added jar:file:/usr/local/abcl-bin-1.4.0/abcl-contrib.jar!/jss/ to ASDF. Added jar:file:/usr/local/abcl-bin-1.4.0/abcl-contrib.jar!/jfli/ to ASDF. Added jar:file:/usr/local/abcl-bin-1.4.0/abcl-contrib.jar!/asdf-jar/ to ASDF. Added jar:file:/usr/local/abcl-bin-1.4.0/abcl-contrib.jar!/abcl-asdf/ to ASDF. ("uiop" "UIOP" "LOOP" "asdf" "ASDF" "abcl-contrib") CL-USER(2): (require "jss") ("COMPILER-TYPES" "KNOWN-FUNCTIONS" "JVM-CLASS-FILE" "JAVA" "KNOWN-SYMBOLS" "DUMP-FORM" "COMPILER-ERROR" "JVM-INSTRUCTIONS" "JVM" "COMPILER-PASS1" "COMPILER-PASS2" "JSS") CL-USER(3): (use-package "JSS") T CL-USER(4): ----
Vibhu
Hello,
Vibhu Mohindra vibhu.mohindra@gmail.com wrote:
You might be missing a: (require "abcl-contrib") line. The following is what works for me. I've got abcl-contrib.jar in the same directory as abcl.jar :
Yes, that was exactly it, in the meantime I algo got help from the IRC channel and that line did the trick, thank you.
Btw, the reason it works in SLime is because it is loaded as part of Slime
Startup completed in 1.73 seconds. Using probed value of abcl-contrib: '/opt/abcl-bin-1.4.0/abcl-contrib.jar'. Added jar:file:/opt/abcl-bin-1.4.0/abcl-contrib.jar!/quicklisp/ to ASDF. Added jar:file:/opt/abcl-bin-1.4.0/abcl-contrib.jar!/mvn/ to ASDF. Added jar:file:/opt/abcl-bin-1.4.0/abcl-contrib.jar!/jss/ to ASDF. (...)
Best regards,
armedbear-devel@common-lisp.net