JNI vs Runtime.exec() [英] JNI vs Runtime.exec()

查看:229
本文介绍了JNI vs Runtime.exec()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个选择 - 我可以使用JNI或使用Runtime.exec来执行C ++库。

I have two options - I can either use JNI or use Runtime.exec to execute a C++ library.

C ++程序是CPU密集型的并且长期运行,即一些电话可能需要几个小时才能返回。

The C++ program is CPU intensive and long running i.e. some calls may take up to a couple of hours to return.

每种电话的优缺点是什么?
我应该采用哪种方法?

What are the pros and cons of each? Which approach should I go for?

推荐答案

如果您需要与C ++库进行交互,请转到JNI。

If you need to interact with the C++ library, go for JNI.

如果它是一个你想要调用的独立程序(也许是获取输出), Runtime.exec()更简单。

If it's a standalone program that you just want to invoke (and perhaps grab the output), Runtime.exec() is much, much simpler.

这篇关于JNI vs Runtime.exec()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆