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

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

问题描述

我在C / C ++中开发应用程序。我更喜欢这两种语言,并且喜欢成为C ++开发人员。我想知道如何创建一个包含我所有C ++代码的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屋!

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