可以在 Eclipse 插件中使用非 Java 代码吗?

发布于 2024-10-06 12:17:36 字数 185 浏览 2 评论 0原文

我已经使用一个工具有一段时间了,我非常喜欢它,我想将它作为 Eclipse 插件。不幸的是,我认为它是用 C++ 编写的。有没有什么方法可以将这样的代码库用作 Eclipse 插件的基础,而无需用 Java 重新编写它?

顺便说一句:该工具是闭源的、商业的、由其他人维护的,需要用作 GUI 小部件。我主要想知道我是否有可能说服业主这样做。

I've been using a tool for a while and I like it so much I'd like to have it as an eclipse plugin. Unfortunately, I think it's written in C++. Is there any way such a code base could be used as the basis for a Eclipse plugin without re-writing it in Java?

BTW: the tool is closed source, commercial, maintained by someone else and would need to be used as a GUI widget. I'm mostly wondering if it would be at all likely that I could talk the owners into doing this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

晚风撩人 2024-10-13 12:17:36

您始终可以使用 JNI

You could always use JNI

寄意 2024-10-13 12:17:36

您可以尝试使用 SWIG (或普通 JNI,这是一个主要的 PITA)为您的 C++ 代码创建 Java 包装器)。

You could try to create Java wrappers for your C++ code using SWIG (or plain JNI, which is a major PITA though).

铁轨上的流浪者 2024-10-13 12:17:36

一般来说,将现有的本机应用程序和工具集成到 Eclipse 中是一项重大工作。如果您想说服维护人员这样做,您必须说服他们为什么移植到 Eclipse 对他们有好处。

但是,如果有合适的 C++ API,您可以自己做很多事情。您可以使用 SWIG 包装 API,或者编写一个包装器可执行文件,使用某些序列化协议进行通信,例如 < a href="http://code.google.com/p/protobuf/" rel="nofollow">Google Protobuf。然而,这不会考虑将 UI 集成到 Eclipse 中,因此如果该工具是 UI 密集型的,这可能不会对您有太大帮助。

In general, integrating existing native applications and tools into Eclipse is a major effort. If you want to talk the maintainers into doing it, you will have to convince them why porting to Eclipse would be good for them.

However, if there is a suitable C++ API, you can do a lot on your own. You can wrap the API using SWIG, or write a wrapper executable which communicates using some for of serialization protocol, for example Google Protobuf. However, this will not take care of integrating the UI in Eclipse, so if the tool is UI-heavy this will probably not help you much.

轻许诺言 2024-10-13 12:17:36

根据它是什么工具,您可以考虑其他一些选项。如果它是代码生成或翻译工具,您可能只需要一个自定义构建器,它可以使用您选择的选项和目标来调用该工具作为构建过程的一部分。例如,您可以将 Visual Studio 构建作为 Eclipse 编译的一部分运行,不会出现任何问题。

或者,如果它是一个图形工具,请检查它是否是一个 COM 对象,它可以“轻松”包装到 Java 中,从而包装到 Eclipse 插件中。

最后,我还想为 SWIG 投一票。这个东西非常好,可以很容易地将 C 或 C++ API 包装到 Java 中并为您生成大量 JNI 代码。

Depending on what tool it is, you may consider a few other options. If it is a code generation or translation tool, you may need nothing more than a custom builder, which can invoke the tool as part of the build process with options and targets of your choosing. For example, you can run a Visual Studio build as part of an Eclipse compilation without problems.

Or if it is a graphical tool, check whether it is a COM object, which can be wrapped "easily" into Java and hence into an Eclipse plugin.

And finally, I would also like to put in a vote for SWIG. This stuff is really good and makes it quite easy to wrap C or C++ APIs into Java and generating a ton of JNI code for you.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文