Fix Java's 'Could Not Find or Load Main Class' Jar error

preview_player
Показать описание
If you try to run a JAR file or even a class at the command line, you may encounter Java's 'Could not find or load main class error.' If you get this while you try to run a JAR file, there are few ways to fix it. Check that a manifest file exists. Check that the main-class attribute is configured in the manifest, and make sure the main class has a properly coded main method. Errors on any of these fronts will cause the 'could not find or load main class' Java error. But if you fix these issues with you JAR, the Java main class error should go away!
Рекомендации по теме
Комментарии
Автор

Still doesn't work, even with manifest, java -cp / java -jar
Error:
Error: Could not find or load main class org.example.Main
Caused by: org.example.Main

bignik
Автор

Always so frustrating when a JAR doesn't run and you get the load main class Java error!

scrumtuous
Автор

I found the JAR file to an old game I used to play 20 years ago, on a site that is long gone. But the file won't run, because of this error. I noticed that when you extracted the file, it's path matched the Main-Class structure (com\mcmz\rps\DesktopGame & com.mcnz.rps.DesktopGame), is that always the case?

When I extract this JAR, they have no folder structure (other than META-INF folder). In this case, would the Main-Class just be the file name? or should there still be a com.XXX.XXX.mainClass structure?

michaelnewsome
Автор

Hi, Mr. McKenzie I came across your video while searching for a solution to execute java jar file. First of all thank you for the video, it is really easy to understand and execute. But unfortunately I couldn't find the main class file in the jar file to compare it manifest.mf. Is there any way to detect it? Or should I go through all of the jar file one by one? Hope you can answer my question or anyone who might have a solution. Have a nice day everyone!

selinbicer
Автор

Hi, Mr. McKenzie I came across your video while searching for a solution to execute java jar file. First of all thank you for the video, it is really easy to understand and execute. But unfortunately I couldn't find the main class file in the jar file to compare it manifest.mf. Is there any way to detect it? Or should I go through all of the jar file one by one? Hope you can answer my question or anyone who might have a solution. Have a nice day everyone!

selinbicer
Автор

bro why does my main class file look like that i'm about to summon the eater of worlds in here😭

repeppe
Автор

I could've used this few days ago... ugh, still awesome! 😃

theboredommachine
Автор

Thank you so much, helped me with my university project

mihajlomadzarevic