Exception in thread “main” java.lang.UnsatisfiedLinkError: no jep in java.library.path

若如初见. 提交于 2021-02-18 08:13:11

问题


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


回答1:


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/ 



回答2:


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.



来源:https://stackoverflow.com/questions/38183062/exception-in-thread-main-java-lang-unsatisfiedlinkerror-no-jep-in-java-librar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!