Giter Site home page Giter Site logo

Comments (7)

eduOS avatar eduOS commented on August 15, 2024

I might have made an embarrassing mistake since the test file is not under the example directory.

from crfpp.

garfieldnate avatar garfieldnate commented on August 15, 2024

Hi eduOS,
libCRFPP.so is created when you run make in the java/ directory, and you need to add the directory containing it to your java.library.path Java variable. However, it also tries to load libCRFPP.lib (or .dll on Windows) created with make in the project root directory. So you need to make both of those available.

You can look at my fork if you are having trouble compiling on Windows (although there is no installation and you have to configure paths manually).

On Linux I installed it like this:

cd crfpp
chmod +x configure
./configure
make
make install
cd java
make
cp CRFPP.jar /usr/local/lib/CRFPP.jar
cp libCRFPP.so /usr/local/lib/libCRFPP.so
echo "/usr/local/lib" >> /etc/ld.so.conf.d/lib.conf
ldconfig

Then I add /usr/local/lib to my java.library.path and it finds everything.

from crfpp.

eduOS avatar eduOS commented on August 15, 2024

Thanks so much for your help. I run into one more error now while make in the java directory:

c++ -O3 -c -fpic CRFPP_wrap.cxx  -I/usr/lib/jvm/java-7-openjdk-amd64/include -I/usr/lib/jvm/java-7-openjdk-amd64/include/linux
CRFPP_wrap.cxx:159:17: fatal error: jni.h: No such file or directory
 #include <jni.h>
                 ^
compilation terminated.
make: *** [all] Error 1

It seems that jni.h file is lost.
My OS is Ubuntu 14.04 and the version of my Java is 1.8.x. Should I change Java 8 to Java 1.7.x?

from crfpp.

garfieldnate avatar garfieldnate commented on August 15, 2024

Yeah, the make files for Linux have hardcoded paths to the Java include files. /usr/lib/jvm/java-7-openjdk-amd64/ probably does not exist. You need to edit the makefile to match your Java installation, probably java-8-... if you installed the latest version.

from crfpp.

eduOS avatar eduOS commented on August 15, 2024

You're right. I have edited the Makefile replacing the java-7 to the path of java-8 directory containing jni.h. But I met this:

c++ -O3 -c -fpic CRFPP_wrap.cxx  -I/home/leo/lerner/Java/jdk1.8.0_71/include -I/home/leo/lerner/Java/jdk1.8.0_71/include/linux
c++ -shared  CRFPP_wrap.o -o libCRFPP.so -lcrfpp -lpthread
javac org/chasen/crfpp/*.java
javac test.java
jar cfv CRFPP.jar org/chasen/crfpp/*.class
/bin/sh: 1: jar: not found
make: *** [all] Error 127

Should I also tell it where to find the jar?
I found that no jar file exists under the java directory.

I have set the path and I can run jar in my zsh terminal but the error appears all the same.

from crfpp.

eduOS avatar eduOS commented on August 15, 2024

I thought the CRFPP.jar cannot be created. Everything about java path is properly set in /etc/profile.
Ironically I can manually create the jar file by:
`jar cfv CRFPP.jar org/chasen/crfpp/*.class``
The question is why cannot the script? Is it that the script uses bash and cannot find the jar command while I, using the zsh, can?

I add the java.library.path by:

    Select your project in the Package Explorer area and press a right click on it.
    Select Build Path → Configure Build Path... option.
    In the appearing window, select the Libraries tab.
    Then, expand the JRE System library option and select the Native library location.
    Click on the Edit... button at the right panel.
    Locate the required library and then click OK.
    Close the window.

or for the terminal:

java -Djava.library.path=/usr/local/lib test

But the fourth error occurred:

Exception in thread "main" java.lang.RuntimeException: feature_index.cpp(193) [mmap_.open(model_filename)] mmap.h(153) [(fd = ::open(filename, flag | O_BINARY)) >= 0] open failed: ../model
    at org.chasen.crfpp.CRFPPJNI.new_Tagger(Native Method)
    at org.chasen.crfpp.Tagger.<init>(Tagger.java:183)
    at test.main(test.java:6)

Normally a model is produced after the training, @garfieldnate I reach the place where you are now. Haha.

from crfpp.

eduOS avatar eduOS commented on August 15, 2024

This issue becomes the same as #26 .

from crfpp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.