问题描述
如何在 java 中实现 vtable COM 接口?
How can I implement a vtable COM interface in java?
在过去,我会使用 Microsft JVM,它内置了 java-COM 互操作.现代 JRE 的等价物是什么?
In the old days, I'd use the Microsft JVM, which had built in java-COM interop. What's the equivalent for a modern JRE?
回答一个类似的SO问题雅各布.我看过 JACOB,但它基于 IDispatch,旨在控制自动化服务器.我需要的 COM 接口是自定义 vtable(扩展 IUnknown),例如IPersistStream、IOleWindow、IContextMenu 等
Answers to a similar SO question proposed JACOB. I've looked at JACOB, but that is based on IDispatch, and is aimed at controlling Automation serers. The COM interfaces I need are custom vtable (extend IUnknown), e.g. IPersistStream, IOleWindow, IContextMenu etc.
对于我的用例,我可以在 JNI 中实现所有 COM 细节,并让 JNI 层调用 java 中的相应接口.但我希望有一个不那么痛苦的解决方案.
For my use case, I could implement all the COM specifics in JNI, and have the JNI layer call corresponding interfaces in java. But I'm hoping for a less painful solution.
这是一个开源项目,所以首选开源替代品.
It's for an open source project, so open source alternatives are preferred.
Com4j 看起来很有希望.查看可用的文档,它似乎不支持注册 IClassFactory,因此 COM 对象(在 java 中)可以由非 java 客户端实例化.
Com4j looks promising. Looking through the available docs, it doesn't seem to support registering a IClassFactory so the COM object (in java) can be instantiated by non-java clients.
推荐答案
Com4J可能是你需要的.从主页:
Com4J may be what you need. From the homepage:
直接绑定到 vtable 接口(不是 IDispatch)用于改进性能和更广泛的支持更多 COM 接口.
Binds directly to the vtable interface (not IDispatch) for improved performance and broader support for more COM interfaces.
这篇关于java-COM interop:用Java实现COM接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!