在Java中包装C / C ++ [英] Wrapping C/C++ inside Java
问题描述
我的意思是,我想把我所有的C ++代码(已经开发的) Java类。但无知如何做到这一点。
请发布您在Java中集成C ++的响应或方法/步骤。
(使用JNI是方式,但我无法弄清楚www如何使用它)
我使用Eclipse IDE开发。
我应该在项目工作区中包含哪些包?
如果你想从Java调用C ++,你需要使用 JNI - Java Native Interface。请注意,由于无法处理C ++对象,因此您将丢失垃圾回收器的一些优点,并且您的代码将不再可移植。
也许你会更好地通过学习写100%的Java和离开C ++,但这只是一个建议。
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.
I mean, I would like to wrap all my C++ code (that is already developed) inside Java class. But clueless how to do it.
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, I use Eclipse IDE to develop.
How and what packages should I include in my project workspace?
If you want to call C++ from Java, you'll need to use JNI - Java Native Interface.
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.
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屋!