标签:mod default system tla 代码 cep lib64 import 文件
不知道具体原理,但是,加载 dll 文件时,带路径或者更改 dll 文件的名字,都会报错。虽然库记载成功了,但是处女座认为这不可接受。于是有了这个解决方案。
在根目录为库创建软连接,然后使用 system.loadLibrary(“libname”) 来加载。事实证明,它时认软连接的。
上代码:
import com.seapine.surroundscm.api.*; import java.lang.UnsupportedOperationException; import java.lang.SecurityException; import java.io.IOException; import java.nio.file.*; public class SurroundSCMAPIExample { static { String arch = System.getProperty("sun.arch.data.model"); Path target; if(arch.equals("32")) { target = FileSystems.getDefault().getPath("lib","sscmapi.dll"); } else { target = FileSystems.getDefault().getPath("lib64","sscmapi.dll"); } Path link = FileSystems.getDefault().getPath("sscmapi.dll"); try { Files.deleteIfExists(link); Files.createSymbolicLink(link, target); } catch (IOException | UnsupportedOperationException | SecurityException e) { if (e instanceof SecurityException) { System.err.println("Permission denied!"); } if (e instanceof UnsupportedOperationException) { System.err.println("An unsupported operation was detected!"); } if (e instanceof IOException) { System.err.println("An I/O error occurred!"); } System.err.println(e); } System.loadLibrary("sscmapi"); } public static void main(String[] args) { SSCMContext context = new SSCMContext(); SSCMResult ret = SSCMAPI.connectRSA("localhost", 4900, "", "admin", "", context); if(SSCMAPI.SSCM_API_OK == ret.result) System.out.println("Connection Succeeded"); else System.out.println("Connection Failed: " + SSCMAPI.getLastError(ret.result)); SSCMAPI.disconnect(context); } }
妥妥的,再看不到任何的报错。
标签:mod default system tla 代码 cep lib64 import 文件
原文地址:https://www.cnblogs.com/pied/p/11133413.html