64 位 Windows 上的 Javax.comm API

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3959743/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 07:36:14  来源:igfitidea点击:

Javax.comm API on 64-bit Windows

javawindows-7serial-portjavax.comm

提问by Nathi

I am using the javax.comm API to help my program communicate with hardware over serial port. I am using the Windows 7 and NetBeans IDE 9.

我正在使用 javax.comm API 来帮助我的程序通过串行端口与硬件通信。我使用的是 Windows 7 和 NetBeans IDE 9。

I used the common Java program to check the available ports on my PC. The program compiled and ran without error. However it returned nothing.

我使用通用 Java 程序来检查 PC 上的可用端口。程序编译并运行没有错误。然而它什么也没返回。

What can I do to use the javax.comm API on Windows? It seems win32com.dll does not work with a 64-bit operating system.

如何在 Windows 上使用 javax.comm API?win32com.dll 似乎不适用于 64 位操作系统。

回答by Stephen C

it seem the win32com.dll does not work with 64-bit Operating system

win32com.dll 似乎不适用于 64 位操作系统

I think that is correct. In fact, according to the relevant download page, Oracle no longer supportsthe javax.commAPI for anyWindows platform.

我认为这是正确的。事实上,根据相关下载页面,Oracle 不再支持任何Windows 平台的javax.commAPI 。

However, I found this pagewhich has a 64bit build of the DLL, among other things.

但是,我发现这个页面有一个 64 位版本的 DLL,等等。

EDIT

编辑

By an astounding piece of research (i.e. following the links and reading stuff) I found the download pagefor the latest RXTX, which claims to have binaries for various platforms. If your platform is not there, try building from source. If that doesn't work, consider investing the effort in making it work.

通过一项惊人的研究(即按照链接和阅读材料),我找到了最新 RXTX的下载页面,该页面声称拥有适用于各种平台的二进制文件。如果您的平台不存在,请尝试从源代码构建。如果这不起作用,请考虑投入精力使其发挥作用。

回答by PeterMmm

Have you got a look on RXTX? I think it is still active.

你看过RXTX吗?我认为它仍然是活跃的。

回答by kaliatech

Recent 2.2pre versions of RXTX include binaries for 64-bit windows. I thinkthe latest RXTX information source has changed to this: http://rxtx.qbang.orginstead of http://www.rxtx.orgthough.

RXTX 的最新 2.2pre 版本包括用于 64 位窗口的二进制文件。我认为最新的 RXTX 信息源已更改为:http: //rxtx.qbang.org而不是http://www.rxtx.org

At one point the RXTX library included drop-in support for using the javax.comm api. I'm not sure if it still does, but the main change then to use the "native" RXTX packaging was primarily just a package name change.

在某一时刻,RXTX 库包含对使用 javax.comm api 的直接支持。我不确定它是否仍然存在,但是使用“原生”RXTX 包装的主要变化主要只是包名称的变化。

回答by wilkanah

I had this issue...on a 64 bit machine..running windows 7

我有这个问题......在 64 位机器上......运行 Windows 7

a legacy application developed in jdk 1.4, for 32 bit windows... and using the win32 comm api binary

在 jdk 1.4 中开发的遗留应用程序,用于 32 位窗口......并使用 win32 comm api 二进制文件

i tried the RXTX binary for 64 bit and i was able to communicate with my device on some level... but... there were other problems as my application referenced a version of the jpos library that internally was using the comm-api (had import javax.comm.*... in some Serial...Listener class)....

我尝试了 64 位的 RXTX 二进制文件,并且我能够在某种程度上与我的设备进行通信......但是......还有其他问题,因为我的应用程序引用了内部使用 comm-api 的 jpos 库版本(在某些 Serial...Listener 类中导入了 javax.comm.*...。...

I installed a 32 bit jdkand setup the comm-api binaries for 32 bit windows as directed here...setup comm api on windows

我安装了32 位 jdk并按照此处的指示为 32 位 Windows 设置了 comm-api 二进制文件...在 Windows 上设置 comm api

all was fine afterwards

之后一切都很好

回答by Gili

You might be interested at an alternative library I've authored: http://code.google.com/p/jperipheral/

您可能对我编写的替代库感兴趣:http: //code.google.com/p/jperipheral/

回答by Lazar

I've integrated RXTX libraries into some of my earlier projects and i found out this bug it has while working with comm ports under windows, so you might want to check this first before going into some serious app design. Communication works fine, never had any problem with that, but once you open the port you cannot close it and reopen, if you use method provided for closing port, your app just hangs, no exception no nothing. I found later the same behavior described by users on web, but never really found the solution to this problem. Again, this might help you save some time, check it first.

我已经将 RXTX 库集成到我的一些早期项目中,并且我发现了它在 Windows 下使用通信端口时存在的这个错误,因此您可能需要先检查一下,然后再进行一些严肃的应用程序设计。通信工作正常,从来没有任何问题,但是一旦您打开端口,您就无法关闭它并重新打开,如果您使用提供的关闭端口的方法,您的应用程序就会挂起,无一例外。我后来在网上发现了用户描述的相同行为,但从未真正找到解决此问题的方法。同样,这可能会帮助您节省一些时间,请先检查一下。

Latest release, which is this http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip, doesn't have this issue no more. Unfortunately i think its solved only for windows, its still there on Linux binaries, and i haven't tried it on mac.

最新版本,即http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip,不再有此问题。不幸的是,我认为它仅适用于 Windows,它仍然存在于 Linux 二进制文件中,我还没有在 mac 上尝试过。

回答by Alan

This is how I got it to work.
I've tested it using JDK 1.6 (32bit) on my Windows 7 64bit machine.

这就是我让它工作的方式。
我已经在我的 Windows 7 64 位机器上使用 JDK 1.6(32 位)对其进行了测试。

  1. Install 32bit JDK.
  2. Copy 'win32com.dll' to JDK_HOME\jre\bin.
  3. Copy 'javax.comm.properties'to to JDK_HOME\jre\lib.
  4. Copy 'comm.jar'to to JDK_HOME\jre\lib\ext.
  1. 安装 32 位 JDK。
  2. 将“win32com.dll”复制到 JDK_HOME\jre\bin。
  3. 将“javax.comm.properties”复制到 JDK_HOME\jre\lib。
  4. 将'comm.jar'复制到JDK_HOME\jre\lib\ext。

Now run your program and it should work.

现在运行你的程序,它应该可以工作了。