paho.mqtt.java icon indicating copy to clipboard operation
paho.mqtt.java copied to clipboard

problem using the mqtt.jar file in a Java 10 project

Open ElkeSombrowski opened this issue 6 years ago • 4 comments

Hi,

I'm trying to use the paho mqtt library in a Java 10 project. It works fine if I put the jar file on the class path. But if I move the jar to the module path and add the line requires org.eclipse.paho.client.mqttv; to module-info.java my project doesn't compile any more, giving the error message: error: module not found: org.eclipse.paho.client.mqttv requires org.eclipse.paho.client.mqttv;

The org.eclipse.paho.client.mqttv3-1.2.1-20180926.040552-201.jar is compiled with Java 1.8.0_162. Is the problem related to the automatic module generation in Java 10? Do you have a solution for this problem? When will a new org.eclipse.paho.client.mqttv.jar be released, which is compiled with a current Java version?

Best regards, Elke

  • [x] Bug exists Release Version 1.2.0 ( Master Branch)
  • [x] Bug exists in MQTTv3 Client on Snapshot Version 1.2.1-SNAPSHOT (Develop Branch)
  • [x] Bug exists in MQTTv5 Client on Snapshot Version 1.2.1-SNAPSHOT (Develop Branch)

ElkeSombrowski avatar Sep 26 '18 07:09 ElkeSombrowski

Hi, I've not tried to compile against Java 10 yet, but I imagine that if there are any issues then they will be resolved in the next release after this one.

jpwsutton avatar Oct 03 '18 07:10 jpwsutton

I'm no expert on this, but org.eclipse.paho.client.mqttv the right name? I would have thought it should end with a 3 at least:

org.eclipse.paho.client.mqttv3

just checking.

icraggs avatar Nov 01 '18 15:11 icraggs

You are right, org.eclipse.paho.client.mqttv3 is needed. But Netbeans can't find this module. If you put org.eclipse.paho.client.mqttv3-1.2.0.jar on the module path only the module org.eclipse.paho.client.mqttv is found.

I suppose that this is due to the automatic module detection, which interprets numeric characters at the end of a name as version number and therefore cuts it off. See: https://docs.oracle.com/javase/9/docs/api/java/lang/module/ModuleFinder.html

ElkeSombrowski avatar Nov 05 '18 10:11 ElkeSombrowski

Hello,

I downloaded the source code of org.eclipse.paho.mqttv5.client Renamed package org.eclipse.paho.mqttv5 to org.eclipse.paho.mqttvv.client Add the src\main\java\module-info.java file:

module org.eclipse.paho.mqttvv.client {
    requires transitive java.se;

    exports org.eclipse.paho.mqttvv.client;
    exports org.eclipse.paho.mqttvv.common;
    exports org.eclipse.paho.mqttvv.common.packet;
}

Recompiled Then I was able to use the module.

yoannsimeoni avatar Mar 16 '22 17:03 yoannsimeoni