2

Hello I have seen this Why am I getting a Java NoSuchPortException when the port exists? post but It's not very clear to me!!

In device manager it shows COM3 is exist and I can connect it through putty, but this piece of code is getting this error/exception.

try {
       portId = CommPortIdentifier.getPortIdentifier("COM3");
    } catch (NoSuchPortException ex) {
       System.out.println(ex);
    }

try {
     serialPort = (SerialPort)portId.open("S2CFrameWork", 5000);
    } catch (PortInUseException e) {
        System.out.println(e);
    }

this simple code thrown a javax.comm.NoSuchPortException, I have also tried this with using Enumeration to get the list of avilable port but still it shows exception. Can anyone solve this issue?

Community
  • 1
  • 1
Shantanu Banerjee
  • 1,417
  • 6
  • 31
  • 51

1 Answers1

6

comm.jar should be placed in:

%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
Shantanu Banerjee
  • 1,417
  • 6
  • 31
  • 51
  • Where can i download this package for windows? – m4heshd Nov 18 '16 at 10:20
  • I have tried given instructions with [link](http://kishor15389.blogspot.rs/2011/05/how-to-install-java-communications.html) and it worked. Instructions for installation and file can be found with given link. – recineshto Jun 18 '17 at 20:06
  • forgot to mention, link was copied from another thread [link](https://stackoverflow.com/questions/7562565/how-to-get-javax-comm-api) – recineshto Jun 18 '17 at 20:20