calling freeling Java API from ABCL

1k views Asked by At

I am trying to call the Freeling (http://nlp.lsi.upc.edu/freeling/) Java API (http://devel.cpl.upc.edu/freeling/svn/trunk/APIs/java/) from ABCL (http://common-lisp.net/project/armedbear/). I followed all the procedure in the README of the Freeling Java API to, using swig, compile the API. After that, I was able to run the example code.

java -Djava.library.path=. -cp freeling.jar:. Analyzer < teste.text > teste.out

In this Analyzer.java, the relevant lines are:

...
import edu.upc.freeling.*;
...
System.loadLibrary( "freeling_javaAPI" );
...
MacoOptions op = new MacoOptions( LANG );

In ABCL I have tried:

(add-to-classpath "/Users/arademaker/Downloads/myfreeling/APIs/java/freeling.jar")
(jstatic "load" "java.lang.System" "/Users/arademaker/Downloads/myfreeling/APIs/java/libfreeling_javaAPI.so")
(jnew "edu.upc.freeling.MacoOptions" "en")

But I got the error:

Java exception 'java.lang.UnsatisfiedLinkError: edu.upc.freeling.freelingJNI.new_MacoOptions(Ljava/lang/String;)J'.
   [Condition of type JAVA-EXCEPTION]

Does anyone have any idea? Any special problem of ABCL with the System.load of Java?

2

There are 2 answers

0
Alexandre Rademaker On

Following the suggestion of Alessio Stalla in http://thread.gmane.org/gmane.lisp.armedbear.devel/2923 I were able to solve my problem. The solution was to load ABCL not with the -jar parameter with:

java -jar abcl.jar

But with the commaand line suggested:

java -Djava.library.path=. -cp freeling.jar:abcl.jar org.armedbear.lisp.Main

It looks like the -jar makes java ignore the -cp parameter:

http://docs.oracle.com/javase/1.4.2/docs/tooldocs/linux/java.html

Nevertheless, it explains part of the mystery because I have also tried:

(add-to-classpath "freeling.jar")

before the

(jstatic "load" "java.lang.System" ".../libfreeling_javaAPI.so")
(jnew "edu.upc.freeling.MacoOptions" "en")

So the use of "-jar" has other consequences besides ignore "-cp" parameter.

0
easyE On

It is considered better form to use JAVA:ADD-TO-CLASSPATH from Lisp, after invoking ABCL.

 (java:add-to-classpath (probe-file #p"freeling.jar"))

should give more information. ABCL has an expansive notion of CL:PATHNAME