gpt4 book ai didi

java - 在 Java 中打开端口时出错

转载 作者:行者123 更新时间:2023-12-01 16:39:30 25 4
gpt4 key购买 nike

我在尝试打开现金抽屉时收到以下错误。

加载 win32com 时出错:java.lang.UnsatisfiedLinkError:C:\Program Files\Java\jdk1.6.0_15\jre\bin\win32com.dll:无法在 AMD 上加载 IA 32 位 .dll 64位平台

我使用的代码如下

import javax.comm.*;  
import java.util.*;
/** Check each port to see if it is open. **/
public class openPort {

public static void main (String [] args) {
Enumeration port_list = CommPortIdentifier.getPortIdentifiers ();

while (port_list.hasMoreElements ()) {
// Get the list of ports
CommPortIdentifier port_id =
(CommPortIdentifier) port_list.nextElement ();

// Find each ports type and name
if (port_id.getPortType () == CommPortIdentifier.PORT_SERIAL)
{
System.out.println ("Serial port: " + port_id.getName ());
}
else if (port_id.getPortType () == CommPortIdentifier.PORT_PARALLEL)
{
System.out.println ("Parallel port: " + port_id.getName ());
} else
System.out.println ("Other port: " + port_id.getName ());

// Attempt to open it
try {
CommPort port = port_id.open ("PortListOpen",20);
System.out.println (" Opened successfully");
port.close ();
}
catch (PortInUseException pe)
{
System.out.println (" Open failed");
String owner_name = port_id.getCurrentOwner ();
if (owner_name == null)
System.out.println (" Port Owned by unidentified app");
else
// The owner name not returned correctly unless it is
// a Java program.
System.out.println (" " + owner_name);
}
}
} //main
} // PortListOpen

最佳答案

该错误清楚地表明您的 dll 是 32 位的。 JVM 也应该是 32 位。

关于java - 在 Java 中打开端口时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5369644/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com