static { try { String libpath = System.getProperty("java.library.path"); if (libpath == null || libpath.length() == 0) { throw new RuntimeException("java.library.path is null"); }
String path = null; StringTokenizer st = new StringTokenizer(libpath, System .getProperty("path.separator")); if (st.hasMoreElements()) { path = st.nextToken(); } else { throw new RuntimeException("can not split library path:" + libpath); }
Class thisClass = HelloWorld.class; InputStream inputStream = thisClass.getResource("HelloWorld.dll") .openStream(); File dllFile = new File(new File(path), "HelloWorld.dll"); if (!dllFile.exists()) { FileOutputStream outputStream = new FileOutputStream(dllFile); byte[] array = new byte[8192]; for (int i = inputStream.read(array); i != -1; i = inputStream .read(array)) { outputStream.write(array, 0, i); } outputStream.close(); // System.loadLibrary("RegistryUtil"); }
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步