kamilfb / mqtt-spy

Please use the new Eclipse Paho GitHub repo instead.
https://github.com/eclipse/paho.mqtt-spy/wiki
346 stars 68 forks source link

Starting fails with "Could not find or load main class" #88

Closed ctron closed 8 years ago

ctron commented 8 years ago

Starting the client on Linux (RHEL 7) fails with:

$ java -jar mqtt-spy-0.5.2-jar-with-dependencies.jar 
Error: Could not find or load main class pl.baczkowicz.mqttspy.Main
kamilfb commented 8 years ago

Hi. What version of java are you on?

ctron commented 8 years ago

1.8.0 Update 91

ctron commented 8 years ago

This is the output of java -version:

openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
ctron commented 8 years ago

This can easily be reproduced by using docker:

$ docker run -ti ubuntu:16.04
docker# apt-get update
docker# apt-get -y install openjdk-8-jre-headless wget
docker# wget https://github.com/kamilfb/mqtt-spy/releases/download/mqtt-spy_v0.5.2/mqtt-spy-0.5.2-jar-with-dependencies.jar
docker# java -version
openjdk version "1.8.0_91"
OpenJDK Runtime Environment (build 1.8.0_91-8u91-b14-0ubuntu4~16.04.1-b14)
OpenJDK 64-Bit Server VM (build 25.91-b14, mixed mode)
docker# java -jar mqtt-spy-0.5.2-jar-with-dependencies.jar 
Error: Could not find or load main class pl.baczkowicz.mqttspy.Main
kamilfb commented 8 years ago

Thanks for the info, I will look into it...

kamilfb commented 8 years ago

Hi @ctron! Have you tried adding "apt-get install openjfx"? Or using "openjdk-8-jre" or "openjdk-8-jdk" instead of "openjdk-8-jre-headless"?

ctron commented 8 years ago

I was already using open jdk 8. And I am on RHEL 7, I don't know if there are any additional openjfx packages. However javafx applications work in general.

But using the docker instructions I posted you should be able to test it pretty easily.

kamilfb commented 8 years ago

@ctron, as mentioned before, you are missing openjfx libs - you can install them with the following command:

apt-get install openjfx

ctron commented 8 years ago

You are right! On Ubuntu it seems as if JavaFX was missing. Installing with apt-get worked.

However on RHEL7/CentOS7 there is no package named "openjfx".

kamilfb commented 8 years ago

Cool - I'm glad it worked on Ubuntu :) I don't think RedHat & CentOS fully support openjfx. The only way forward is probably to use the Oracle's JRE/JDK when on RHEL/CentOS. If you hit any more problems, just re-open it or raise a new issue.

ctron commented 8 years ago

Ok, so no luck for me ;-)

But thanks for your help!

kamilfb commented 8 years ago

Why can't you use Oracle's JRE instead?

stephen-smith commented 5 years ago
java -cp '/usr/share/openjfx/lib:/usr/share/openjfx/lib/*:mqtt-spy-1.0.1-beta-b18-jar-with-dependencies.jar' pl.baczkowicz.mqttspy.Main
Error: JavaFX runtime components are missing, and are required to run this application

OpenJFX is installed. If there's a more recent beta, I'm willing to try it, but I can't find where I got this one anymore. https://askubuntu.com/a/1138493 (via https://openjfx.io/openjfx-docs/) strongly implies that the JavaFX runtime components are no longer part of the JRE, and should instead be included in your executable, with-dependencies, jar.

stephen-smith commented 5 years ago

java --module-path /usr/share/openjfx/lib --add-modules javafx.base,javafx.controls,javafx.fxml -jar mqtt-spy-1.0.1-beta-b18-jar-with-dependencies.jar seems to work, though you might need to add even more JavaFX modules.

zorbali commented 4 years ago

it doesnt work on my system. Anybody knows complete set of package list and instructions how to install and run this in linux 20.04

riker65 commented 3 years ago

same for me :+1: it doesnt work on my system. Anybody knows complete set of package list and instructions how to install and run this in linux 20.04

zorbali commented 3 years ago

Try the command below,

it should work however every time you upgrade or restart the computer you must make sure that the java version below is the one selected to run.

sudo apt install openjfx=8u161-b12-1ubuntu2 libopenjfx-java=8u161-b12-1ubuntu2 libopenjfx-jni=8u161-b12-1ubuntu2

It took me long time to find out the correct version. Let me know if this worked please. Regards,Chris Paraskevaides.


From: riker65 notifications@github.com Sent: 29 September 2020 12:58 To: kamilfb/mqtt-spy mqtt-spy@noreply.github.com Cc: zorbali cparaskevaides@hotmail.com; Comment comment@noreply.github.com Subject: Re: [kamilfb/mqtt-spy] Starting fails with "Could not find or load main class" (#88)

same for me 👍 it doesnt work on my system. Anybody knows complete set of package list and instructions how to install and run this in linux 20.04

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/kamilfb/mqtt-spy/issues/88#issuecomment-700684812, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AMXUWGSKLP6KXJ2SJ3VZ6ATSIHKXJANCNFSM4CJASSDA.

kyrsjo commented 3 years ago

@ctron I know this is a very old bug, however at least on Fedora 32, it started after installing with dnf:

So for anyone playing along at home, the correct command to install dependencies appears to be: sudo dnf install openjfx java-1.8.0-openjdk-openjfx

It is however really confusing that the error message one gets these are not installed is:

$ java -jar mqtt-spy-1.0.0.jar 
Error: Could not find or load main class pl.baczkowicz.mqttspy.Main

which seems to indicate that the problem is in the mqttspy package, especially since the "getting started" documentation refers to a non-existent .jar mqtt-spy-0.3.0-jar-with-dependencies.jar.

Then after installing openjfx the error is:

$ java -jar mqtt-spy-1.0.0.jar 
Graphics Device initialization failed for :  es2, sw
Error initializing QuantumRenderer: no suitable pipeline found

which is fixed by installing the openjdk link.

Hopefully this is useful for anyone trying to get mqttspy started! onwards to figuring out whats wrong with mosquitto

karls0 commented 2 years ago

Hi, I really love your programm. It is a great help, when I am writing code for ESPs using MQTT. After updating my OS to Mint20.3, which is based on Ubuntu 20.04, mqtt-spy is not starting anymore.

karls@mintbox20:~/tools/mqtt-spy$ java -jar mqtt-spy-1.0.0.jar Fehler: Hauptklasse pl.baczkowicz.mqttspy.Main konnte nicht gefunden oder geladen werden Ursache: java.lang.NoClassDefFoundError: javafx/application/Application

Googling around I found a lot of evidnce that openjfx might cause this. Finally I arrived here.

My java-version is: openjdk version "11.0.13" 2021-10-19 OpenJDK Runtime Environment (build 11.0.13+8-Ubuntu-0ubuntu1.20.04) OpenJDK 64-Bit Server VM (build 11.0.13+8-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)

apt-get install openjfx tells me: openjfx ist schon die neueste Version (11.0.7+0-2ubuntu2) .

zorbalis tip did not work, I got: E: Version »8u161-b12-1ubuntu2« für »openjfx« konnte nicht gefunden werden.

Any help appreciated, Karl

Mentor-Roma commented 1 year ago

Have been facing a similar issue for a couple of days now and I seems to have something on Windows.

After adding the modules and libraries from javafx, the mqtt-spy windows opens, but with some errors on command line. And with this, connecting to the local broker doesn't work.

However, starting the mqtt-spy with the java app itself did solve all problems and I was able to create a connection to the local broker. Running this on command line did work for me "C:\Program Files\Java\jre-1.8\bin\java" -jar mqtt-spy-1.0.0.jar hope it helps someone

consolacion commented 8 months ago

Eventhough I have the open jfx installed, I get: Could not find or load main class pl.baczkowicz.mqttspy.Main Caused by: java.lang.NoClassDefFoundError: javafx/application/Application oddly, MQTT-spy has worked perfectly for me in the past