关于Java:COMM API安装中的错误:nblibraries.properties文件不存在

Error in COMM API Installation: nblibraries.properties file doesn't exist

我正在尝试运行此示例代码,该示例代码从此处查询可用的com端口:http://www.java2s.com/Code/Java/Development-Class/QueryingAvailableCOMPorts.htm

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Install the Java Comm API first. if there is no necessary file, say Dll files, the API
// won't work.

import java.util.Enumeration;

import javax.comm.*;
import java.util.Enumeration;

public class ListPorts {
  public static void main(String args[]) {
    Enumeration ports = CommPortIdentifier.getPortIdentifiers();
    while (ports.hasMoreElements()) {
      CommPortIdentifier port = (CommPortIdentifier) ports.nextElement();
      String type;
      switch (port.getPortType()) {
      case CommPortIdentifier.PORT_PARALLEL:
        type ="Parallel";
        break;
      case CommPortIdentifier.PORT_SERIAL:
        type ="Serial";
        break;
      default: /// Shouldn't happen
        type ="Unknown";
        break;
      }
      System.out.println(port.getName() +":" + type);
    }
  }
}

我已将comm api正确添加到我的项目中,我可以在我的项目的Libraries文件夹下看到我的comm.jar文件。但是当我构建项目时,netbeans会给我以下消息:

ant -f C:\\Users\\Timur\\Documents\
etBeansProjects\\KEYCON clean jar
C:\\Users\\Timur\\Documents\
etBeansProjects\\KEYCON\
bproject\\build-impl.xml:63:
Source resource does not exist:
C:\\Users\\Timur\\Desktop\\javax.comm\
blibraries.properties BUILD FAILED
(total time: 0 seconds)

当我尝试运行项目时,Netbeans会显示以下消息:

run: Error loading win32com: java.lang.UnsatisfiedLinkError: no
win32com in java.library.path BUILD SUCCESSFUL (total time: 0 seconds)

我应该将comm.jar文件专门存储在某个地方吗?现在在我的桌面上。还是因为其他原因而出现问题?


这个社区没有回答的另一个问题:/

我还是自己写了一个答案。所以这里是:

但是事情是我在这里写的,通常是针对该站点或其他站点上类似问题的相同解决方案,但我最初的8-9次都没有解决。

For the jdk (Java Developnment Kit) to recognize the serial ports on
your machine, it is important to properly place these files in the
right folders on your local machine :

%Java_HOME% = the location of your jdk directory.

To Find your JDK directory, Use the Following steps:

  • Click on Start
  • Click on Search
  • Click on For Files or Folders a€|
  • In the Left hand Side, Click on All Files and Folders
  • Type in jdk* in the textbox under All or part of the file name:
  • Click Search
  • Look for yellow icon that looks like a folder
  • Double Clikc on the folder to open the jdk folder
  • comm.jar should be placed in:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    %JAVA_HOME%/lib

    %JAVA_HOME%/jre/lib/ext win32com.dll should be placed in:

    %JAVA_HOME%/bin

    %JAVA_HOME%/jre/bin

    %windir%System32 javax.comm.properties should be placed in:

    %JAVA_HOME%/lib

    %JAVA_HOME%/jre/lib