如何编译C ++&爪哇 [英] How to compile C++ & java

查看:105
本文介绍了如何编译C ++&爪哇的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
请问有人知道如何用C ++文件编译Java文件吗?
非常感谢.

Hi all,
May i ask if anyone know how to compile a java file with a C++ file?
Thanks alot.

推荐答案

否!

C ++和Java是不同语言!不要混合它!
就像是一顿素食,上面放着培根.
一块很好的巧克力蛋糕,配以番茄酱或
一件白色的衬衫,在洗涤时变粉红色.

请勿尝试!
NO!

C++ and Java are DIFFERENT languages! DO NOT MIX IT!
It''s like a vegetarian meal with bacon on top.
A nice piece of chocolate cake with ketchup or
a white shirt that got pink while washing.

DO NOT TRY THIS!


几乎不可能"进行编译",因为编译后的可执行文件可解决不兼容的目标(Java在虚拟机上运行,​​与平台无关,C ++不是).

通过Java本机接口可以实现某些互操作性,该接口允许您调用用C ++或相反编写的DLL. http://download.oracle.com/javase/1.5.0/docs/guide/jni/index.html [ ^ ].不过,请做好吞咽技术的准备.

另一个选择是将C ++.NET代码与J#.NET代码(均在.NET框架上运行)混合,即使J#不是纯Java.

如果您的源文件中的一个文件不太大,请考虑使用另一种语言重写,这可能是一种更快的解决方案.
"compile with" is virtually impossible because the compiled executables address incompatible targets (Java runs on a virtual machine to be platform independent, C++ not).

Some interoperability is possible via the Java Native Interface that will allow you to invoke DLLs written in C++ or conversely. http://download.oracle.com/javase/1.5.0/docs/guide/jni/index.html[^]. Be ready to swallow technicalities, though.

Another option could be to mix C++.NET code with J#.NET code (both running on the .NET framework), even though J# is not pure Java.

If one of your source file is not too big, consider rewriting in the other language, this may be a faster solution.


当然您不能将JavaC++,但是,您可以使用JNIJava调用C++代码,反之,例如,参见此处 [ ^ ].
Of course you can''t compile together Java and C++, however, you may call C++ code from Java and the opposite, using JNI, see, for instance, here[^].


这篇关于如何编译C ++&爪哇的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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