title: getting error when compiling for modbus rs232
body: <p>i am new in java... i am trying to read on modbus. PLC is slave device and it is configured well. my java file is unable to read modbus values.here is the code..given below. error is coming at master.init(); method. please help me in this case.    </p>
  
  <pre><code>package com.mod4j;
  import java.io.File;
  import gnu.io.SerialPort;
  import com.serotonin.io.serial.SerialParameters;
  import com.serotonin.*;
  import com.serotonin.modbus4j.ModbusFactory;
  import com.serotonin.modbus4j.ModbusMaster;
  import com.serotonin.modbus4j.code.DataType;
  import com.serotonin.modbus4j.code.RegisterRange;
  import com.serotonin.modbus4j.exception.ModbusInitException;
  import com.serotonin.modbus4j.locator.BaseLocator;
  import com.serotonin.modbus4j.locator.NumericLocator;
  import com.serotonin.modbus4j.msg.ReadCoilsRequest;
  import com.serotonin.modbus4j.msg.ReadCoilsResponse;
  import com.serotonin.modbus4j.msg.ReadDiscreteInputsRequest;
  import com.serotonin.modbus4j.msg.ReadHoldingRegistersRequest;
  import com.serotonin.modbus4j.msg.ReadHoldingRegistersResponse;
  import com.serotonin.modbus4j.msg.ReadInputRegistersRequest;
  import com.serotonin.modbus4j.msg.ReadInputRegistersResponse;
  import com.serotonin.modbus4j.msg.WriteCoilRequest;
  import com.serotonin.modbus4j.msg.WriteCoilResponse;
  import com.serotonin.modbus4j.msg.WriteRegistersRequest;
  import com.serotonin.modbus4j.msg.WriteRegistersResponse;
  import gnu.io.*;
  
  public class Modbus4JTest
  {
  
      public static void main(String[] args) throws Exception
      {  
  
     try 
     {
     SerialParameters params = new SerialParameters();
     params.setCommPortId("COM1");
     params.setBaudRate(9600);
     params.setDataBits(8);
     params.setStopBits(1);
     params.setParity(0);
  
     ModbusFactory modbusFactory = new ModbusFactory();
     ModbusMaster master = modbusFactory.createRtuMaster(params);
     master.setTimeout(100);
     master.setRetries(3);
  
     byte [] RIR,RHR,RDI,RCR;
     int slaveId=1;
     int startOffset=0;
     int numberOfRegisters=10;
     int numberOfBits=10;
  
     try
     {
          master.init();
          while (true) 
          {
                  ReadInputRegistersRequest reqRIR = new ReadInputRegistersRequest(slaveId, startOffset, numberOfRegisters);
                  System.out.println("ReadInputRegistersRequest reqRIR =" +reqRIR);
                  ReadInputRegistersResponse resRIR = (ReadInputRegistersResponse) master.send(reqRIR);
                  RIR = resRIR.getData();
                  System.out.println("InputRegisters :" + RIR);
  
                  ReadHoldingRegistersRequest reqRHR = new ReadHoldingRegistersRequest(slaveId, startOffset, numberOfRegisters);
                  ReadHoldingRegistersResponse resRHR = (ReadHoldingRegistersResponse) master.send(reqRHR);
                  RHR=resRHR.getData();
                  System.out.println("HoldingRegister :" + RHR);
  
                  ReadDiscreteInputsRequest reqRDI= new ReadDiscreteInputsRequest(slaveId, startOffset, numberOfBits);
                  ReadCoilsResponse resRDI = (ReadCoilsResponse) master.send(reqRDI);
                  RDI=resRDI.getData();
                  System.out.println("DiscreteInput :" + RDI);
  
                  ReadCoilsRequest reqRCR = new ReadCoilsRequest(slaveId, startOffset, numberOfBits);
                  ReadCoilsResponse resRCR = (ReadCoilsResponse) master.send(reqRCR);
                  RCR=resRCR.getData();   
                  System.out.println("CoilResponce :" + RCR);
  
                  short[] sdata = null;
                  WriteRegistersRequest reqWR = new WriteRegistersRequest(slaveId, startOffset, sdata);
                  WriteRegistersResponse resWR = (WriteRegistersResponse) master.send(reqWR);
  
                  int writeOffset = 0;
                  boolean writeValue = true;
                  WriteCoilRequest reqWC = new WriteCoilRequest(slaveId, writeOffset, writeValue);
                  WriteCoilResponse resWC = (WriteCoilResponse) master.send(reqWC);
  
                  Thread.sleep(1000);
               }//end while
          }//end try
         catch (Exception e) 
         {
  
              e.printStackTrace();
     }//end catch
  
    finally 
     {
         master.destroy();
     }//end finally
   }//end try
  catch (Exception e)
  {
      e.printStackTrace();
  }//end catch
  
  }// end main
      }//end class Modbus4JTest
  </code></pre>
  
  <p>this is java file i am running.</p>
  
  <p>and here are the error i have got after compiling..
  please suggest what went wrong and please correct me at ...
  is there any step by step tutorial or any demo video please give me link at<br>
  ayyaz.nadaf@gmail.com</p>
  
  <pre><code>Exception in thread "main" java.lang.NoClassDefFoundError:      
  jssc/SerialPortException
  at com.serotonin.io.serial.SerialUtils.openSerialPort(SerialUtils.java:94)
  at com.serotonin.modbus4j.serial.SerialMaster.init(SerialMaster.java:58)
  at com.serotonin.modbus4j.serial.rtu.RtuMaster.init(RtuMaster.java:45)
  at com.mod4j.Modbus4JTest.main(Modbus4JTest.java:58)
  Caused by: java.lang.ClassNotFoundException: jssc.SerialPortException
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.net.URLClassLoader$1.run(Unknown Source)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.net.URLClassLoader.findClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
  at java.lang.ClassLoader.loadClass(Unknown Source)
  ... 4 more
  </code></pre>