1 Reply Latest reply: May 13, 2011 3:20 AM by 796440 RSS

    NullPointerException when get serial port.


      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)
      return new CommPortEnumerator();

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

      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!