有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java jar问题查找端口系列Rs232

我的申请有点小问题 起初,我测试了它,它是有效的,但当我把我的项目构建到jar中时!这是个小问题-/

好吧,我解释我的问题:当我用cmd>;appli\dist\appli。jar我有我的界面,但我有一个bouton,我在那里寻找一个可用的端口,当我点击这个按钮时,它不工作(我找不到有效的端口)

另一方面,当我用cmd>;java-jar appli\dist\appli。jar这工作很好

我用-Xlint:Unchecked重新编译了我的程序,得到了以下警告: 警告:[未选中]未选中将(K,V)作为原始类型java的成员的调用。util。哈希图 港口地图。put(curPort.getName(),curPort); 1警告

以下是我的方法:

public void searchForPorts()
{

  //for containing the ports that will be found
  public Enumeration ports = null;
  //map the port names to CommPortIdentifiers
  public HashMap portMap = new HashMap();

    ports = CommPortIdentifier.getPortIdentifiers();

    while (ports.hasMoreElements())
    {
        CommPortIdentifier curPort = (CommPortIdentifier)ports.nextElement();

        //get only serial ports
        if (curPort.getPortType() == CommPortIdentifier.PORT_SERIAL)
        {

            window.cboxPorts.addItem(curPort.getName());
            portMap.put(curPort.getName(), curPort);
        }
    }
}

ps:抱歉我的英语不好,我不是以英语为母语的人:)


共 (0) 个答案