java web (servlet)中,使用Opencv的方法。解决一直报错(no opencv_java320 in java.library.path)解决办法

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_32846595/article/details/83060149

  最近要在servlet 中使用opencv,发现在java文件中,使用main可以跑通的代码,在servlet中不能跑通了。

    //动态加载dll
	private void loaddllDynamically() {			
        String yourdllpath=“”//输入你要的dll路径,例如“c:/opencv/”,路径下为opencv_320,dll位置
		try {
            //设置路径
			System.setProperty("java.library.path",yourdllpath + System.getProperty("java.library.path"));
			System.out.printf("java.library.path: %s%n",System.getProperty("java.library.path"));	             
	        Field fieldSysPath;
			fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
		    fieldSysPath.setAccessible(true);		    		  
		    fieldSysPath.set(null, null);			
		    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
		} catch (NoSuchFieldException  |SecurityException | IllegalArgumentException | IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
 		
	}

猜你喜欢

转载自blog.csdn.net/qq_32846595/article/details/83060149