我在尝试打开现金抽屉时收到以下错误。
加载 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/