核心代码示例
@PostConstruct
private void initDll() throws IOException {
String dllPath = this.getClass().getResource(“/dll/”).getPath() + “DwgOperInterface.dll”;
if (dllPath.indexOf(“.jar”) > 0) {
dllPath = dllPath.substring(0, dllPath.lastIndexOf(“.jar”));
dllPath = dllPath.substring(6, dllPath.lastIndexOf(“/”));
dllPath = File.separator + dllPath + “/DLL”;
copyDir(dllPath);
System.out.println(“dll加载路径:” + dllPath);
System.load(dllPath + “/DwgOperInterface.dll”);
} else {
System.load(dllPath);
}
}
/**
-
复制文件夹下所有文件
-
@author tarzan LIU
-
@date 2020/10/22
*/
private void copyDir(String javaUrl) throws IOException {
URL url = JNIMapUtil.class.getClassLoader().getResource(“dll/”);
Strin