Please Note This forum exists for community support for the Mango product family and the Radix IoT Platform. Although Radix IoT employees participate in this forum from time to time, there is no guarantee of a response to anything posted here, nor can Radix IoT, LLC guarantee the accuracy of any information expressed or conveyed. Specific project questions from customers with active support contracts are asked to send requests to support@radixiot.com.

Radix IoT Website Mango 3 Documentation Website Mango 4 Documentation Website

Error Importing Modbus4J Library in Netbeans


  • Hi.
    I am trying this library, I have funded the test code in the src/Test
    I have added the code to fresh NetBeans project and import the Modbus4J library from the right side library import panel.
    but still its showing error in the code.
    I tried with alt+enter but it's not showing to import option.

    package modbustestlibrery;
    /**
     *
     * @author mdism
     */
    public class myModbus {
    
        /**
         * @param args the command line arguments
         */
            public static void main(String[] args) throws Exception {
                
         ModbusFactory factory = new ModbusFactory();
         IpParameters params = new IpParameters();
         params.setHost("localhost");
         params.setPort(12345);
         ModbusMaster master = factory.createTcpMaster(params, true, false);
         // master.setRetries(4);
         master.setRetries(0);
         try {
         master.init();
         master.getValue(1, RegisterRange.HOLDING_REGISTER, 0, DataType.TWO_BYTE_INT_UNSIGNED);
         }
         finally {
         master.destroy();
         }
         }
        
    }
    
    
    This is the error i am getting 
    
    Compiling 1 source file to D:\work\practice\Wifi\Java Test\ModbusTestLibrery\build\classes
    D:\work\practice\Wifi\Java Test\ModbusTestLibrery\src\modbustestlibrery\myModbus.java:19: error: cannot find symbol
         ModbusFactory factory = new ModbusFactory();
      symbol:   class ModbusFactory
      location: class myModbus
    D:\work\practice\Wifi\Java Test\ModbusTestLibrery\src\modbustestlibrery\myModbus.java:19: error: cannot find symbol
         ModbusFactory factory = new ModbusFactory();
      symbol:   class ModbusFactory
      location: class myModbus
    D:\work\practice\Wifi\Java Test\ModbusTestLibrery\src\modbustestlibrery\myModbus.java:20: error: cannot find symbol
         IpParameters params = new IpParameters();
      symbol:   class IpParameters
      location: class myModbus
    D:\work\practice\Wifi\Java Test\ModbusTestLibrery\src\modbustestlibrery\myModbus.java:20: error: cannot find symbol
         IpParameters params = new IpParameters();
      symbol:   class IpParameters
      location: class myModbus
    D:\work\practice\Wifi\Java Test\ModbusTestLibrery\src\modbustestlibrery\myModbus.java:23: error: cannot find symbol
         ModbusMaster master = factory.createTcpMaster(params, true, false);
      symbol:   class ModbusMaster
      location: class myModbus
    D:\work\practice\Wifi\Java Test\ModbusTestLibrery\src\modbustestlibrery\myModbus.java:28: error: cannot find symbol
         master.getValue(1, RegisterRange.HOLDING_REGISTER, 0, DataType.TWO_BYTE_INT_UNSIGNED);
      symbol:   variable RegisterRange
      location: class myModbus
    D:\work\practice\Wifi\Java Test\ModbusTestLibrery\src\modbustestlibrery\myModbus.java:28: error: cannot find symbol
         master.getValue(1, RegisterRange.HOLDING_REGISTER, 0, DataType.TWO_BYTE_INT_UNSIGNED);
      symbol:   variable DataType
      location: class myModbus
    7 errors
    

    1_1524135873781_Error2.png 0_1524135873775_Error1.png

    Please help.


  • Seems like a path issue. Is modbus4j on your classpath?