I am trying to use a C++ library called FreeLing from ABCL (using the library JAVA API). I have just posted a question in http://stackoverflow.com/questions/17556912/calling-freeling-java-api-from- abcl. Does anyone know of any limitation of ABCL to deal with the System.load of Java?
Best, Alexandre
I don't know the details of System.loadLibrary enough to answer your question; however: the Java code and the Lisp code differ in the use of loadLibrary() vs load(). Have you tried using the same method in both cases?
On Tue, Jul 9, 2013 at 10:06 PM, Alexandre Rademaker arademaker@gmail.com wrote:
I am trying to use a C++ library called FreeLing from ABCL (using the library JAVA API). I have just posted a question in http://stackoverflow.com/questions/17556912/calling-freeling-java-api-from- abcl. Does anyone know of any limitation of ABCL to deal with the System.load of Java?
Best, Alexandre
On 10 July 2013 00:27, Alessio Stalla alessiostalla@gmail.com wrote:
I don't know the details of System.loadLibrary enough to answer your question; however: the Java code and the Lisp code differ in the use of loadLibrary() vs load(). Have you tried using the same method in both cases?
If I understand correctly, loadLibrary() loads a library from the system load paths, and modifies the name passed to it (so that loadLibrary("foo") will load foo.dll on windows and libfoo.so on unixes), load() loads any file as a dynamic library, and doesn't do the name modification.
On Tue, Jul 9, 2013 at 11:34 PM, Ville Voutilainen ville.voutilainen@gmail.com wrote:
On 10 July 2013 00:27, Alessio Stalla alessiostalla@gmail.com wrote:
I don't know the details of System.loadLibrary enough to answer your question; however: the Java code and the Lisp code differ in the use of loadLibrary() vs load(). Have you tried using the same method in both cases?
If I understand correctly, loadLibrary() loads a library from the system load paths, and modifies the name passed to it (so that loadLibrary("foo") will load foo.dll on windows and libfoo.so on unixes), load() loads any file as a dynamic library, and doesn't do the name modification.
Right. I mean that it's probably useful to try and replicate the exact semantics of the Java code in Lisp first, just to eliminate any doubt that the problem is not caused by ABCL.
So I would launch ABCL as:
java -Djava.library.path=. -cp abcl.jar org.armedbear.lisp.Main
And I would run the following Lisp code:
(jstatic "loadLibrary" "java.lang.System" "freeling_javaAPI") (jnew "edu.upc.freeling.MacoOptions" "en")
If you get the same error, then it is definitely a problem with ABCL. If not, it might be something else.
Alessio -- Some gratuitous spam:
http://ripple.com Ripple, social credit system http://common-lisp.net/project/armedbear ABCL, Common Lisp on the JVM http://code.google.com/p/tapulli my Lisp open source projects http://www.manydesigns.com/ ManyDesigns Portofino, open source model-driven Java web application framework
I have tried both System.load and System.loadSystem. Apparently the problem is how the abcl is initiated:
Following @Alessio suggestion, that is, using abcl.jar in the classpath and start the org.arbedbear.lisp.Main, it works:
urca:java arademaker$ java -Djava.library.path=. -cp freeling.jar:/usr/local/abcl-bin-1.1.1/abcl.jar org.armedbear.lisp.Main Armed Bear Common Lisp 1.1.1 Java 1.6.0_51 Apple Inc. Java HotSpot(TM) 64-Bit Server VM Low-level initialization completed in 0.494 seconds. Startup completed in 2.187 seconds. Loading /Users/arademaker/.abclrc completed in 9.59 seconds. Type ":help" for a list of available commands. CL-USER(1): (jstatic "loadLibrary" "java.lang.System" "freeling_javaAPI") NIL CL-USER(2): (jnew "edu.upc.freeling.MacoOptions" "en") #<edu.upc.freeling.MacoOptions edu.upc.freeling.MacoOptions@716.... {11ACBF5C}>
But following my original way, that is, start abcl using the -jar option, it fails!! Why is that? What is the right way to start ABCL?
urca:java arademaker$ java -Djava.library.path=. -cp freeling.jar:. -jar /usr/local/abcl-bin-1.1.1/abcl.jar Armed Bear Common Lisp 1.1.1 Java 1.6.0_51 Apple Inc. Java HotSpot(TM) 64-Bit Server VM Low-level initialization completed in 0.41 seconds. Startup completed in 1.956 seconds. Loading /Users/arademaker/.abclrc completed in 8.559 seconds. Type ":help" for a list of available commands. CL-USER(1): (jstatic "loadLibrary" "java.lang.System" "freeling_javaAPI") NIL CL-USER(2): (jnew "edu.upc.freeling.MacoOptions" "en") #<THREAD "interpreter" {270D75A3}>: Debugger invoked on condition of type ERROR Class not found: edu.upc.freeling.MacoOptions Restarts: 0: TOP-LEVEL Return to top level.
Best.,
Alexandre Rademaker http://arademaker.github.com/
On 10 July 2013 17:00, Alexandre Rademaker arademaker@gmail.com wrote:
I have tried both System.load and System.loadSystem. Apparently the problem is how the abcl is initiated:
Following @Alessio suggestion, that is, using abcl.jar in the classpath and start the org.arbedbear.lisp.Main, it works:
urca:java arademaker$ java -Djava.library.path=. -cp freeling.jar:/usr/local/abcl-bin-1.1.1/abcl.jar org.armedbear.lisp.Main Armed Bear Common Lisp 1.1.1 Java 1.6.0_51 Apple Inc. Java HotSpot(TM) 64-Bit Server VM Low-level initialization completed in 0.494 seconds. Startup completed in 2.187 seconds. Loading /Users/arademaker/.abclrc completed in 9.59 seconds. Type ":help" for a list of available commands. CL-USER(1): (jstatic "loadLibrary" "java.lang.System" "freeling_javaAPI") NIL CL-USER(2): (jnew "edu.upc.freeling.MacoOptions" "en") #<edu.upc.freeling.MacoOptions edu.upc.freeling.MacoOptions@716.... {11ACBF5C}>
But following my original way, that is, start abcl using the -jar option, it fails!! Why is that? What is the right way to start ABCL?
See eg. http://manuelselva.wordpress.com/2009/02/10/java-cp-and-jar/. It seems that -jar causes -cp to be ignored...
On 10 July 2013 17:09, Ville Voutilainen ville.voutilainen@gmail.comwrote:
On 10 July 2013 17:00, Alexandre Rademaker arademaker@gmail.com wrote:
I have tried both System.load and System.loadSystem. Apparently the problem is how the abcl is initiated:
Following @Alessio suggestion, that is, using abcl.jar in the classpath and start the org.arbedbear.lisp.Main, it works:
urca:java arademaker$ java -Djava.library.path=. -cp freeling.jar:/usr/local/abcl-bin-1.1.1/abcl.jar org.armedbear.lisp.Main Armed Bear Common Lisp 1.1.1 Java 1.6.0_51 Apple Inc. Java HotSpot(TM) 64-Bit Server VM Low-level initialization completed in 0.494 seconds. Startup completed in 2.187 seconds. Loading /Users/arademaker/.abclrc completed in 9.59 seconds. Type ":help" for a list of available commands. CL-USER(1): (jstatic "loadLibrary" "java.lang.System" "freeling_javaAPI") NIL CL-USER(2): (jnew "edu.upc.freeling.MacoOptions" "en") #<edu.upc.freeling.MacoOptions edu.upc.freeling.MacoOptions@716.... {11ACBF5C}>
But following my original way, that is, start abcl using the -jar option, it fails!! Why is that? What is the right way to start ABCL?
See eg. http://manuelselva.wordpress.com/2009/02/10/java-cp-and-jar/. It seems that -jar causes -cp to be ignored...
Indeed. http://docs.oracle.com/javase/1.4.2/docs/tooldocs/linux/java.html says about -jar that "When you use this option, the JAR file is the source of all user classes, and other user class path settings are ignored."
Hello Ville,
It explains part of the mystery because I have also tried:
(add-to-classpath "freeling.jar")
before the
(jstatic "load" "java.lang.System" "/Users/arademaker/Downloads/myfreeling/APIs/java/libfreeling_javaAPI.so") (jnew "edu.upc.freeling.MacoOptions" "en")
So the use of -jar has other consequences besides ignoring the -cp parameter. Am I right?
Best,
Alexandre Rademaker http://arademaker.github.com/
armedbear-devel@common-lisp.net