java,System.loadlibrary(“someDLLFile”)得到不满意的链接错误 [英] java, System.loadlibrary("someDLLFile") gets unstatisfied link error

查看:140
本文介绍了java,System.loadlibrary(“someDLLFile”)得到不满意的链接错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了一些JNI钩子到C ++库,并为我的java服务器项目创建了一些DLL文件。假设DLL和jar文件在C:/ server下的同一文件夹中



我正在访问这些DLL文件:

  System.loadLibrary(someDLLFile); 

在需要C ++代码的类中。



我遇到的问题是当我在我自己的机器上运行这个服务器,一切工作正常,无论我放在服务器文件夹。但是当我把它交给同事测试时,他们会不断得到:

  java.lang.UnsatisfiedLinkError java.library中没有someDLLFile .path 



我想让DLL文件与jar文件在同一文件夹中,没有人配置他们的PATH变量。



为什么System.loadLibrary()在我自己的机器上工作,而不管文件夹的位置,而不是在另一台计算机上?

解决方案

它的工作原理是DLL(或它依赖的DLL,即msvcr90.dll或某物)在您的机器上的PATH,但不是在另一个。 / p>

设置PATH env-var或java.library.path属性以包含您的文件的dir,或存储您的dll,java默认情况下,取决于部署策略和平台)。


I have written some JNI hooks into a C++ library and created some DLL files for my java server project. Lets say the DLL and jar files are in the same folder under "C:/server"

I am accessing these DLL files using:

System.loadLibrary("someDLLFile");

in the class that needs the C++ code.

The problem I am running into is when I run this server on my own machine, everything works fine regardless of where I place the "server" folder. But when I give it to a colleague to test, they continually get:

java.lang.UnsatisfiedLinkError no someDLLFile in java.library.path

I want to have the DLL files live in the same folder as the jar files and would prefer not having someone configure their PATH variable.

Why does System.loadLibrary() work on my own machine regardless of the folder's location, but not on another computer?

解决方案

It works because the DLL (or a DLL it depends on, i.e. msvcr90.dll or something) are in the PATH on your machine, but not on the other one.

Either set PATH env-var or the java.library.path property to contain the dir with your file, or store your dll where java finds it by default (Many options here, depending on deployment strategy and platform).

这篇关于java,System.loadlibrary(“someDLLFile”)得到不满意的链接错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆