JNA

在java中可以使用jna 加载dll,或者so文件

例如

    public IEC61850Worker() {
        try {
            String libpath = DEFAULT_EMPTY;
            if (OsInfoUtil.isLinux()) {
                libpath = BundleHelper.getClassDir();
                libpath += "libiec61850.so";
            } else {
                libpath = OsInfoUtil.getUserDir();
                String jdkbit = OsInfoUtil.getJdkBit();
                libpath += OsInfoUtil.getFileSeparator() + "lib";
                libpath += OsInfoUtil.getFileSeparator() + "libiec61850_"+jdkbit+".dll";
            }
            Logger.info("IEC61850Worker.init.libpath:"+libpath);
            libIec61850 = (LibIec61850)Native.loadLibrary(libpath, LibIec61850.class);
        } catch (Exception e) {
            e.printStackTrace();
            Logger.error("IEC61850Worker.init.error:"+e.getMessage());
        }
    }

在项目中的文件目录

需要在pom文件中引用

    <dependency>
        <groupId>com.sun.jna</groupId>
        <artifactId>jna</artifactId>
        <version>3.0.9</version>
    </dependency>
原文地址:https://www.cnblogs.com/YangBinChina/p/12118111.html