3

I have 'libjep.so' file after downloading jep and I also had set the environmental variable LD_LIBRARY_PATH in ~./bashrc as shown below:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/python2.7/dist-packages/jep/libjep.so

as well as in runtime

System.load("/usr/local/lib/python2.7/dist-packages/jep/libjep.so"); 

But when I have the follwing line in my code,

Jep jep = new Jep();

It shows the below error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no jep in java.library.path
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
    at java.lang.Runtime.loadLibrary0(Runtime.java:870)
    at java.lang.System.loadLibrary(System.java:1122)
    at jep.Jep$TopInterpreter$1.run(Jep.java:118)
    at java.lang.Thread.run(Thread.java:745)

Thanks

Vikrant Kashyap
  • 6,398
  • 3
  • 32
  • 52
Tamil
  • 31
  • 1
  • 3

2 Answers2

2

You need to set the LD_LIBRARY_PATH to the directory containing your library, and not your library itself like this

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/python2.7/dist-packages/jep/

You can also try adding this argument to the java command when you start your java application so java can find the library

-Djava.library.path=/usr/local/lib/python2.7/dist-packages/jep/ 
bsteffen
  • 371
  • 2
  • 9
  • I have tried your solution by adding it into the java argument, however, the error message now is: Exception in thread "main" jep.JepException: : No module named jep – Jonathan Liono May 19 '17 at 06:43
  • @JonathanLiono That error typically indicates that you have more than one python installed on your system and the libpython.so being used is part of a python that does not have jep installed. Try adding the location of the correct libpython to the LD_LIBRARY_PATH or LD_PRELOAD – bsteffen May 19 '17 at 20:27
  • It's correct. But you need to execute your code including the jep-3.8.2.jar file. For example: java -classpath /path/to/jar/jep-3.8.2.jar -jar foo.jar – Vitrion Apr 03 '19 at 00:04
0

The java.lang.UnsatisfiedLinkError occurs only when if the required library is not in the path or it is already loaded. Couple of things you need to make sure is :

1) You're performing System.load(....) inside static block so that its executed only once.
2) Also, you can try removing extension.

Rahul Yadav
  • 1,503
  • 8
  • 11
  • Thanks for you reply. Still, anyway I set that in LD_LIBRARY_PATH then why it is showing the error? – Tamil Jul 04 '16 at 11:16