java - JACOB - 对 COM 接口(interface)的远程调度调用

标签 java com serial-port jacob

我使用 JACOB 来将消息写入 COM 接口(interface)。

Dispatch dispatch = new Dispatch("<Interface Name>");
Variant response = Dispatch.call(dispatch, <DISPID>, message);

这在本地主机上完美运行。但是我如何使用 JACOB api 调用其他机器/IP 地址上的接口(interface)

最佳答案

JACOB 似乎无法远程访问(DCOM 调用)。

JACOB Project mailing-list FAQ

Can I call COM component across machines or operating systems?
The answer to this question is No. The way jacob is implemented is using JNI and a c++ DLL designed for the windows platform. COM is a binary standard defined by Microsoft as it hasn’t been ported over (as far as I know) to any other platforms yet. Jacob is only a java bridge for COM which defines how components talk to each other when they are on the same machine. The DCOM standard defines how components communicate across networks, but Jacob has no support for DCOM.

解决方案:

  • J-Integra 等商业产品本身就支持 DCOM 协议(protocol)。
  • 使用 RMI。为 Jacob 类制作一个包装器,并对其进行 RMI 化。它确实有效,但 Jacob 领导不想让类实现可序列化,这使得整个操作有点困难。
  • 使用网络服务。将您想要的内容公开为 Web 服务,并使用 SOAP 和 Java 端的小吃来访问它。

或者,如果本地工作的 COM 对象内部支持远程访问,这可能会很有用。

看起来就像下面的文章。

Jacob connect to Remote Computer for WMI support

ADODB Recordset Example

The JACOB Project: A JAva-COM Bridge

Downloads
The JACOB binary distribution (jacobBin_XX.zip) includes:

  1. jacob.jar: a JAR file for the java classes which you must add to your CLASSPATH. The package names replace com.ms with com.jacob (for example com.ms.com.Variant maps to com.jacob.com.Variant.
  2. jacob.dll: a small Win32 DLL which you must add to your PATH.
  3. samples: provided in Java source and compiled form to demonstrate various features of the product. In particular, a set of wrapper classes for Microsoft® ADO are provided as samples.

The source code is available in the JACOB source distribution (jacobSrc_XX.zip), which includes both the Java and C++ code. The source distribution is a superset of the binary one, so you don't need both.

<小时/>

其他人似乎有其他库,而不是 JACOB。

A pure Java DCOM Bridge with j-interop

j-interop/j-interop/src/readme.htm

<小时/>

此外:

同样,通过局域网连接的计算机之间也不能调用。

而且,无法用VC++或.NET语言远程调用本地COM对象。

解决方法是创建一个代理应用程序来调用远程计算机上的本地 COM 对象。

任意设计主应用程序和代理应用程序,以便它们可以使用套接字或其他方式相互通信。

关于java - JACOB - 对 COM 接口(interface)的远程调度调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55940428/

相关文章:

java - 为什么 rs.Next() 跳过列

java - lombok key 已经注册

Java 和 PHP session

c# - 在 C# 中使用 ASP ScriptingContext 请求集合?

c++ - 转换 COM 接口(interface)

c++ - 尝试从表单运行线程

java - 在 ScrollView 中以编程方式创建 View

c++ - 基接口(interface)类中缺少虚拟析构函数?

java - Android中从USB串口读取数据

c# - 将数据写入文本文件