jagrosh / MusicBot

🎶 A Discord music bot that's easy to set up and run yourself!
https://jmusicbot.com
Apache License 2.0
5.27k stars 2.53k forks source link

[Bug Report] Jmusic-0.4.0 jar file - a java exception has occured #1497

Closed itsCrummy closed 1 month ago

itsCrummy commented 6 months ago

Bug Description

Steps to Reproduce

download the latest, then attempt to run it after setting up the file

Expected Result

to load up the music bot

Debug Output

cannot get bot to load - just has a the following thing in the image below image

Additional Info

No response

Checklist

siggijarl commented 6 months ago

same here

MichailiK commented 6 months ago

I believe this is because we have upgraded to Java 11 in version 0.4.0 & you're using Java 8 at the moment. Can you check if you have Java 8 & if you do, upgrade to 11?

siggijarl commented 6 months ago

seems to work with AdoptOpenJDK x64 11 which can be handily installed via ninite dot com

itsCrummy commented 6 months ago

I believe this is because we have upgraded to Java 11 in version 0.4.0 & you're using Java 8 at the moment. Can you check if you have Java 8 & if you do, upgrade to 11?

that was the reason why - its fixed now thanks

GenFangirl commented 6 months ago

Can you expand on how to update Java? I downloaded version 11 (11.0.22) and confirmed it is the version I am using by typing java -version into the cmd, but I am still getting the error when trying to run the bot.

jagrosh commented 6 months ago

With just that screenshot it's a bit hard to debug. For anyone still running into this issue, can you share the output of running both java -version and java -jar JMusicBot-0.4.0.jar on the command line

GenFangirl commented 6 months ago

Not sure how helpful this is, but here is my output: CMDOutputMusicBot

jagrosh commented 6 months ago

Can you navigate to the folder (cd .. to move up a directory, cd directoryname to move into a directory) that contains the jar; that particular error is just saying that the jar isn't in the folder you're running the command from

GenFangirl commented 6 months ago

Okay, got this image image

GenFangirl commented 6 months ago

I went and turned off "Pubic Bot" in the Developer Dashboard, and the bot is now running. But it only opens when stared from the cmd. When I close it and attempt to just open it by clicking the executable, I get the "A Java Exception has occurred" error.

GamingTimDE commented 6 months ago

Since when did it change that public mode has to be turned off? I ran into the same problem that the bot didn't start after the update. I only found out the error after starting the bot manually with Java -jar. I had always included it in the autostart of the virtual machine.

itsCrummy commented 6 months ago

With just that screenshot it's a bit hard to debug. For anyone still running into this issue, can you share the output of running both java -version and java -jar JMusicBot-0.4.0.jar on the command line

the issue was because i didnt know i needed Java 11 Lmao - and i dont run it via CMD - but i downloaded Java 11 and it worked so :)

TheDjRider commented 6 months ago

I also encountered this bug. If I have the bot with 'Pubic Bot' on JMuiscBot, it crashes after loading in the user list.

openjdk version "11.0.22" 2024-01-16
OpenJDK Runtime Environment (build 11.0.22+7-post-Debian-1deb11u1)
OpenJDK 64-Bit Server VM (build 11.0.22+7-post-Debian-1deb11u1, mixed mode, sharing)
jagrosh commented 6 months ago

Please keep in mind that the issue we are tracking is a java exception occurring. This happens immediately upon double-clicking the jar in a desktop environment.

GogoDG commented 5 months ago

I have the same problem. I have java 21 installed and 4.0 jar fails to start.

GamingTimDE commented 5 months ago

@GogoDG public mode has to be turned off in 4.0 idk why they changed. Very disappointed

MichailiK commented 5 months ago

From this commit comment:

JMusicBot documentation has always instructed users to mark their bots as private. This update is the first update that actually enforces the instructions. The people complaining about this change are likely the vocal minority.

  • JMusicBot's internals are not optimized for running publicly; there are many design patterns within the code that are designed for ease-of-use or ease-of-maintenance that do not scale well to large numbers of servers.

  • The support server frequently has cases of users asking how to remove their bot from someone's server, and the root issue in most of these cases is that they didn't realize that their bot could be added by anyone.

  • (Hopefully this is not as much of an issue as it has been in the past) People have attempted to pass JMusicBot off as their own bot; some have even attempted to get their bot verified (running a bot that they potentially had zero idea how the internals worked).

  • This change does not prevent the bot owner from adding it to servers.

  • This check only occurs at startup; it is still possible to temporarily make it public if the bot owner isn't able to add it to a server that someone else would be able to.

AlmostHuman34 commented 3 months ago

With just that screenshot it's a bit hard to debug. For anyone still running into this issue, can you share the output of running both java -version and java -jar JMusicBot-0.4.0.jar on the command line

Is there an option to use it now just by double clicking without using cmd? I can open it only via commands you provided.

jagrosh commented 2 months ago

I have a feeling that the root cause is multiple java installations, and the install that Windows picks when double-clicking is different from the default one on the Path when using command line. A potential way to help debug this is to make a dummy jar that is compiled with an older version of java that can display the current java version when launched.

One solution that may be worth investigating would be using something like JSmooth to wrap the jar in an exe file. This might solve some other issues too, like default file types (people accidentally opening the jar in winrar), and possibly even default-filepath issues (where sometimes the 'current directory' doesn't match the jar when double-clicking). If we went this route, we'd need to figure out how to use JSmooth in Github Actions.

AlmostHuman34 commented 1 month ago

With just that screenshot it's a bit hard to debug. For anyone still running into this issue, can you share the output of running both java -version and java -jar JMusicBot-0.4.0.jar on the command line

Is there an option to use it now just by double clicking without using cmd? I can open it only via commands you provided.

OK! I found the solution, I uninstalled java 8 and then I installed Java SE Development Kit 11.0.23 from Oracle (skipping their login with bugmenot) and it works, all the versions have no issues with" java exception has occurred"

jagrosh commented 1 month ago

Excellent, I suspect that an Adoptium install of Java 11 would have worked as well; I think it was the existence of Java 8 that was causing the problems.

Either way, this seems to be resolved; I'd still like to look into JSmooth but that can be tracked separately. Thanks for the investigation.