Java Jni 调用任意目录DLL.(No dll in java libarary path)

 
 
  static
    {
	    Method llm;
	    try {
		    //获取私有的方法 loadLibrary0
		    llm = ClassLoader.class.getDeclaredMethod("loadLibrary0", new  Class[]{Class.class,File.class});
		    llm.setAccessible(true);//破解权限
		    String path = new File("").getAbsolutePath();
		    llm.invoke(null, new Object[]{SendRev.class,new File(path + "\\lib\\test.dll")});
	    } catch (Exception e) {
	    e.printStackTrace();
	    }
    }


你可能感兴趣的:(Java Jni 调用任意目录DLL.(No dll in java libarary path))