MQTT connection error on 2021b - Unable to resolve the name com.mathwo​rks.mqttcl​ient.clien​t.Client.

16 visualizzazioni (ultimi 30 giorni)
I'm facing this error while trying to create an mqtt connection:
>> myMQTT=mqtt('tcp://broker.hivemq.com')
'com.mathworks' package and subpackages will be removed in a future release. There is no simple replacement for this.
Caused by:
Unable to resolve the name com.mathworks.mqttclient.client.Client.
I just downloaded the mqtt package from file -exchange (mqtt-download).
I'm using matlab 2021b:
-----------------------------------------------------------------------------------------------------
MATLAB Version: 9.11.0.2358333 (R2021b) Update 7
MATLAB License Number:
Operating System: Microsoft Windows 10 Pro Version 10.0 (Build 19045)
Java Version: Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
-----------------------------------------------------------------------------------------------------
MATLAB Version 9.11 (R2021b)
Database Toolbox Version 10.2 (R2021b)
Deep Learning Toolbox Version 14.3 (R2021b)
Image Acquisition Toolbox Version 6.5 (R2021b)
Image Processing Toolbox Version 11.4 (R2021b)
MATLAB Compiler Version 8.3 (R2021b)
MATLAB Compiler SDK Version 6.11 (R2021b)
MATLAB Report Generator Version 5.11 (R2021b)
Spreadsheet Link Version 3.4.6 (R2021b)
Statistics and Machine Learning Toolbox Version 12.2 (R2021b)

Risposte (1)

Samay Sagar
Samay Sagar il 27 Ago 2024
Hi Eduardo,
I have faced a similar issue in the past. To address this issue while trying to create an MQTT connection you need to ensure that the necessary Java Archive (JAR) files are included in the dynamic Java class path. . You can use the “javaaddpath” function to add entries to dynamic Java class path.
javaaddpath(path_to_mqttasync.jar)
javaaddpath(path_to_org.eclipse.paho.client.mqttv3-1.1.0.jar)
To verify that the JAR files were added correctly, run the “javaclasspath” command in MATLAB command window. This will display the current Java class paths, and you should see your JAR files listed under "Dynamic Java Path."
You can now try to establish a MQTT connection.
myMQTT=mqtt('tcp://broker.hivemq.com')
For more information about “javaaddpath” and “javaclasspath” refer the following documentation:

Categorie

Scopri di più su MATLAB Compiler SDK in Help Center e File Exchange

Tag

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by