java web JNative调用dll动态链接库:和注意方法

import org.xvolks.jnative.JNative;­

import org.xvolks.jnative.Type;­

import org.xvolks.jnative.exceptions.NativeException;­

public class Dll {­

­

  public static final Integer WriteVirementLogInfo(String info) throws NativeException, IllegalAccessException{­

       //方法 一指向的是系统目录C:/WINDOWS/system32(在web工程下时路径为 例tomcat/bin)­

/*该功能调用了第三放jar JNative-1.3.2.zip­

  * 注意事项如果该项目是web工程时需要将JNativeCpp.dll放到web 服务器的bin中­

  * 否则会报java.lang.IllegalStateException: JNative library not loaded, sorry ! ­

  */­

  System.loadLibrary("csss");//csss指的是动态链接库名­

  //方法二­

  //System.load("C://WINDOWS//system32//csss.dll");  ­

       JNative n = null;­

      /*­

       * csss:动态连接库名;WriteVirementLogInfo:动态连接库的内部方法­

       */­

  n = new JNative("csss","WriteVirementLogInfo");­

  n.setRetVal(Type.INT);//返回类型整型Type.INT­

  int i =0;­

  n.setParameter(i++,Type.STRING ,info);//方法的了内部参数info 为字符(Type.STRING)类型  ­

  n.invoke();//加载­

  return Integer.parseInt(n.getRetVal());   ­

  }­

你可能感兴趣的:(JAVA)