尝试打开钱箱时出现以下错误。在Java中打开端口时出错
Error loading win32com: java.lang.UnsatisfiedLinkError: C:\Program Files\Java\jdk1.6.0_15\jre\bin\win32com.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
我使用的代码如下
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
我有NetBeans在此版本的JDK上工作。如果我现在将其更改为64位,会不会有任何问题?我应该删除Java,并应重新安装我的仪式?如果我安装64位JDK,我正在开发的应用程序可以在所有平台上工作吗? – Deepak 2011-03-20 16:12:23
考虑到安装了正确的comm api,您的应用程序将在所有平台和JDK上运行时没有问题。通常,我建议留在32位Java上,因为它在64位Windows版本上速度更快,但似乎Comm API使用本地DLL,所以在64位Windows上,似乎需要64位JDK和Comm API,并且在32位窗户的32位通讯API。去尝试一下。对于IDE而言,它不起作用,您还可以使用IDE的32位JVM和64位JDK从IDE运行程序。 – Daniel 2011-03-20 16:15:21
我不想改变我的JVM版本。有没有其他方法可以解决这个问题? – Deepak 2011-03-20 16:16:35