2 Replies Latest reply: May 13, 2011 2:49 PM by jschellSomeoneStoleMyAlias RSS

    NullPointerException when get serial port.

    FanXiaogang
      Hi,

      I use the comm.jar to get serial port, but failed.

      error log:
      java.lang.NullPointerException: name can't be null
      at java.io.FilePermission.init(FilePermission.java:171)
      at java.io.FilePermission.<init>(FilePermission.java:249)
      at java.lang.SecurityManager.checkDelete(SecurityManager.java:990)
      at javax.comm.CommPortIdentifier.getPortIdentifiers(CommPortIdentifier.java:24)

      I check the code in comm.jar.

      public static Enumeration getPortIdentifiers()
      {
      SecurityManager securitymanager = System.getSecurityManager();
      if(securitymanager != null)
      securitymanager.checkDelete(propfilename);
      return new CommPortEnumerator();
      }

      Because securitymanager is not null, invoke checkDelete(propfilename) method. If securitymanager is null, it is all right.

      Questions:
      1.what is the SecurityManager function here, is the value default null?
      2.I put the comm.jar in my class path, also refer the win32com.dll file. But what is the reason for the error?

      Thanks in advance!