在Java中包含C / C ++ [英] Wrapping C/C++ inside Java

查看:170
本文介绍了在Java中包含C / C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用C / C ++开发应用程序/程序。我更加精通这两种语言,并喜欢成为一名C ++开发人员。我想知道如何创建一个包含所有我的C ++代码的Java程序。

I develop applications/programs in C/C++. I am more versed in these two languages and love being a C++ developer. I am wondering how to create a Java program that contains all my C++ code.

我的意思是,我想把所有的C ++代码Java类。但是无能的如何做到。

I mean, I would like to wrap all my C++ code (that is already developed) inside Java class. But clueless how to do it.

请发表您的回应或方法/步骤,在Java中整合C ++。
(使用JNI是方法,但我不能在www如何使用它)

Please post your responses or methods/steps on integrating C++ inside Java. (using JNI is the way, but I could not figure it out on www how to use it)

FYI,我使用Eclipse IDE

FYI, I use Eclipse IDE to develop.

如何和我应该在我的项目工作区中包含什么包?

How and what packages should I include in my project workspace?

推荐答案

如果你想从Java调用C ++,你需要使用 JNI - Java本机接口。

If you want to call C++ from Java, you'll need to use JNI - Java Native Interface.

请注意,您会失去垃圾回收器的一些好处,因为它无法处理您的C ++对象,您的代码将不再可移植。

Be warned that you lose some of the benefits of the garbage collector, since it can't deal with your C++ objects, and your code won't be portable anymore.

也许你最好通过学习编写100%Java并留下C ++,但这只是一个建议。

Maybe you'd be better served by learning to write 100% Java and leaving C++ behind, but that's just a suggestion.

这篇关于在Java中包含C / C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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