请问谁有C++通过jna或者jNative调用java方法的例子? 急用,在线急等。网上这方面例子太少 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 JNA只能用于Java调用C的方法JNI可以相互调用。所以,你可以用JNI,到网上搜JNI调用Java方法,会搜到一大堆资料 /** * @company suteam * @author masj * @since Aug 2, 2010 * @version 1.0 */@SuppressWarnings("deprecation")public class SwapToClientManagerImpl implements SwapToClientManager { private static final Log logger = LogFactory.getLog(SwapToClientManagerImpl.class); static JNative myjnative = null; private static String path = ""; public boolean addControl(String filename, String password, String serverIP) throws MessageException { try { if (myjnative == null) { myjnative = new JNative(path+"objctrl.dll", "AddControl"); myjnative.setRetVal(Type.INT); } int i = 0; myjnative.setParameter(i++, filename); myjnative.setParameter(i++, password); myjnative.setParameter(i++, serverIP); myjnative.invoke(); int result = myjnative.getRetValAsInt(); if (result == 1) return true; } catch (Exception e) { logger.error("...", e); throw new MessageException("...."); } finally { if (myjnative != null) { try { myjnative.dispose(); } catch (Exception e) { } } } return false; }} proguard有没有这样的功能 关于WEBGIS,有经验的进来看下 报错java.lang.ClassCastException: java.lang.Long怎办? java初中级水平提高方法 关于action得到前台动态循环出的值!!!!!!!!!!!!!!!!!!!!!!! jsp编码 Hibernate的fetch问题,都琢磨一晚上了 装过J2EE SDK还需要装J2SE SDK吗? Struts标签疑问 java 子类有没有继承父类的私有属性和私有方法呢 关于个人职业的技术规划,速来围观 list.get(i)=超重,甘油三脂(TG)偏高,肝囊肿 怎么去掉里面的逗号?
JNI可以相互调用。
所以,你可以用JNI,到网上搜JNI调用Java方法,会搜到一大堆资料
/**
* @company suteam
* @author masj
* @since Aug 2, 2010
* @version 1.0
*/
@SuppressWarnings("deprecation")
public class SwapToClientManagerImpl implements SwapToClientManager { private static final Log logger = LogFactory.getLog(SwapToClientManagerImpl.class); static JNative myjnative = null;
private static String path = ""; public boolean addControl(String filename, String password, String serverIP)
throws MessageException {
try {
if (myjnative == null) {
myjnative = new JNative(path+"objctrl.dll", "AddControl");
myjnative.setRetVal(Type.INT);
}
int i = 0;
myjnative.setParameter(i++, filename);
myjnative.setParameter(i++, password);
myjnative.setParameter(i++, serverIP); myjnative.invoke();
int result = myjnative.getRetValAsInt(); if (result == 1)
return true;
} catch (Exception e) {
logger.error("...", e);
throw new MessageException("....");
} finally {
if (myjnative != null) {
try {
myjnative.dispose();
} catch (Exception e) {
}
}
} return false;
}
}