我遇到了一个问题 我已经部署了一个 war 文件,当我通过 tomcat 在本地运行时它工作正常但是当我通过提供我的系统 ip 和项目文件夹在另一个系统上运行时,例如
http:\192.168.0.145\DllTest 它加载了小程序,但是当我单击按钮加载功能时它抛出异常
线程“AWT-EventQueue-3”java.lang.UnsatisfiedLinkError 中的异常:需要库的绝对路径:http:\192.168.0.145:8080\DllTest\lib\jinvoke.dll
虽然它在本地工作正常但在另一个系统中却不行。请告诉我问题是什么。
是配股还是其他。
最佳答案
您不能在外部主机上加载 DLL。它必须是一个绝对的磁盘文件系统——正如异常消息已经暗示的那样。最好的办法是手动下载它,创建一个临时文件并加载它。
File dllFile = File.createTempFile("jinvoke", ".dll");
InputStream input = new URL(getCodeBase(), "lib/jinvoke.dll").openStream();
OuptutStream output = new FileOutputStream(dllFile);
// Write input to output and close streams the usual Java IO way.
// Then load it using absolute disk file system path.
System.loadLibrary(dllFile.getAbsolutePath());
dllFile.deleteOnExit();
关于java - 在tomcat中部署,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3787075/