This discussion is archived
2 Replies Latest reply: May 13, 2011 12:49 PM by jschellSomeoneStoleMyAlias RSS

NullPointerException when get serial port.

FanXiaogang Newbie
Currently Being Moderated

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

error log:
java.lang.NullPointerException: name can't be null
at java.lang.SecurityManager.checkDelete(
at javax.comm.CommPortIdentifier.getPortIdentifiers(

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!


  • Correct Answers - 10 points
  • Helpful Answers - 5 points