I have seen this question asked so many times, but there was no precise answer to my problem. My story is simple - I downloaded a legitimate JAR file, for a functioning and advertised application, from here: https://github.com/kamilfb/mqtt-spy/wiki/Downloads .
The application brings the obvious instruction to start it as java -jar mqtt-spy-0.2.0-jar-with-dependencies.jar
but that results in the well known error, being in my case Error: Could not find or load main class pl.baczkowicz.mqttspy.Main
My system is Ubuntu 15.04, Java version is openjdk version "1.8.0_45-internal" OpenJDK Runtime Environment (build 1.8.0_45-internal-b14) OpenJDK 64-Bit Server VM (build 25.45-b02, mixed mode)
I don't have another computer to test it elsewhere. I did some checks and the JAR file looks pretty much normal. I even tried de-compressing it and running the class directly, it won't budge, same error message. I tried some online.class analysis tools, nothing caught my attention. Also I reviewed about a dozen of pages referring to "Could not find or load" problem. No luck so far.
Not sure if anyone bothers, but I did my Java Programmers certification with Sun yet in 2005... and I feel frustrated now. While I hope there is an easy solution for my problem, eg some nice Ubuntu issue;-), I am ready to dig deeper, and looking for any hints that would guide me to finding the root cause of this issue.
Additionally install Java FX, since this is required and worked for me (Ubuntu 16: package openfx):
apt install openjfx
See also this issue: https://github.com/kamilfb/mqtt-spy/issues/88
I currently successfully run it on openjdk version "1.8.0_121" here.
Thank you it was very helpful for me. I had exactly the same problem, and looking the solution here as well
My fix was:
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
then, install the JDK Oracle 8
sudo apt-get install oracle-java8-installer
and then, checking java:
sudo update-alternatives --config java
It is displayed between other choices:
0 /usr/lib/jvm/java-8-oracle/jre/bin/java 1082
auto mode
......
Press to keep the current choice [*]
, or type selection number:
I keep the 0 current choice [*]
then, running mqttspy worked just fine :-)
java -jar mqtt-spy-0.5.1-jar-with-dependencies.jar
在我的案例中起作用的解决方案是使用Oracle的HotSpot Java 8。
Just in case you have multiple java versions, you can run the jar file by giving the java file path as well.
brew install --cask liberica-jdk@17-full
brew install --cask liberica-jdk17-full
/Library/Java/JavaVirtualMachines/liberica-jdk-17-full.jdk/Contents/Home/bin/java -jar mqtt-spy-1.0.1-beta-b18-jar-with-dependencies.jar
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.