开发者

Any possible way to use Tokyo Cabinet in Eclipse?

开发者 https://www.devze.com 2023-01-07 05:42 出处:网络
Just spend 3 straight hours trying to solve the java.lang.UnsatisfiedLinkError: no jtokyocabinet in java.library.path problem in Eclipse in Linux.

Just spend 3 straight hours trying to solve the java.lang.UnsatisfiedLinkError: no jtokyocabinet in java.library.path problem in Eclipse in Linux.

  • Downloaded TC and TC-Java sources,
  • Built them both using ./config --prefix=/usr (so everything "JNI" rela开发者_运维问答ted should be in /usr/lib)
  • Set the LD_LIBRARY_PATH=/usr/lib and CLASSPATH="$CLASSPATH:/usr/local/lib/tokyocabinet.jar" and exported both in .profile
  • Imported tokyocabinet.jar into the project.

Am I missing a setting other than the proper -Djava.library.path=. settings? I can't even find anything on the net about jtokyocabinet on the web or in the documentation. What's the secret sauce to getting this thing to work?


try to make a link to libjtokyocabinet.so...0 in your JAVA_HOME/jre/lib/i386.


it is because your code can not find tokyocabinet's *.so and *.a files, usually they are in /usr/local/lib, run the following command:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

and then try your code again.


Have the same problem, in my case, using OpenSUSE 12.3 64 bits and Eclipse. First, the kyotocabinet-java package can be downloaded from this repository:

http://download.opensuse.org/repositories/devel:/libraries:/c_c++/openSUSE_12.3/

This package provide /usr/lib64/libjkyotocabinet.so.1.1.0 that is the library used by the kyotocabinet jar you can get from maven or the official site. Looking for this lib I found that there is created a slink:

xxxx@xxxx:/usr/lib64> ls -al /usr/lib64/libjkyoto*
/usr/lib64/libjkyotocabinet.so.1 -> libjkyotocabinet.so.1.1.0
/usr/lib64/libjkyotocabinet.so.1.1.0

I just created a new slink without the ".1" at the end...

sudo ln -s libjkyotocabinet.so.1.1.0 libjkyotocabinet.so

/usr/lib64/libjkyotocabinet.so -> /usr/lib64/libjkyotocabinet.so.1.1.0

And all worked alright, seems that

System.loadLibrary("jkyotocabinet");

don't work if the library name is ended with something different to ".so"


Yes, you're missing something. Eclipse controls its own classpath, so whatever you set up in the environment outside Eclipse is likely not to have any effect.

You need to go into the properties for your project, find the "Build Path" settings and add the path to your tc.jar (or jars) to your build path there.

It may be easier to set up a /lib directory within your eclipse project, copy your tokyo jar there and add that to your build path. That way, it becomes part of your project (and can move from Eclipse installation to Eclipse installation) rather than being an external system dependency.

0

精彩评论

暂无评论...
验证码 换一张
取 消