[java] What does "Could not find or load main class" mean?

Here's another issue that took me a bit of time: The command line class path param doesn't behave as you'd expect. I'm on MacOS calling the CLI directly, and I'm including two jars in the call.

For example, both of these were confusing the tool about the name of the main class:

This one because the asterisk was causing it to parse the args incorrectly:

java -cp path/to/jars/* com.mypackage.Main

And this one because -- I'm not sure why:

java -cp "*.jar" com.mypackage.Main

This worked:

java -cp "path/to/jars/*" com.mypackage.Main

Listing the two jars explicitly also worked:

java -cp path/to/jars/jar1.jar:path/to/jars/jar2.jar com.mypackage.Main

Examples related to java

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How much should a function trust another function How to implement a simple scenario the OO way Two constructors How do I get some variable from another class in Java? this in equals method How to split a string in two and store it in a field How to do perspective fixing? String index out of range: 4 My eclipse won't open, i download the bundle pack it keeps saying error log

Examples related to class

String method cannot be found in a main class method Class constructor type in typescript? ReactJS - Call One Component Method From Another Component How do I declare a model class in my Angular 2 component using TypeScript? When to use Interface and Model in TypeScript / Angular Swift Error: Editor placeholder in source file Declaring static constants in ES6 classes? Creating a static class with no instances In R, dealing with Error: ggplot2 doesn't know how to deal with data of class numeric Static vs class functions/variables in Swift classes?

Examples related to main

String method cannot be found in a main class method How to access global variables Maven Error: Could not find or load main class Eclipse error "Could not find or load main class" Error: Main method not found in class Calculate, please define the main method as: public static void main(String[] args) What does "Could not find or load main class" mean? C# importing class into another class doesn't work In Python, can I call the main() of an imported module? Can there exist two main methods in a Java program? Could not find or load main class with a Jar File