Java

The by far best MQTT client for Java/JVM is Paho . Add the dependencys for the library or download the jar files and include them into the project. The following code snippet show how you can connect to a server and publish/subscribing a message. Check the webpage linked above for futher information.

ClientId is the unique MQTT client id to use for the device. If set to "" or None, the Paho library will generate a client id automatically.

The full code example can be found here: https://github.com/CloudMQTT/java-mqtt-example