
Reason #2 - the application's classpath is incorrectly specified java Įxample #2 - a filename or pathname rather than a class name: java ListUser.classĮxample #3 - a class name with the casing incorrect: java Įxample #4 - a typo java Įxample #5 - a source filename java ListUser.javaĮxample #6 - you forgot the class name entirely java lots of arguments When the class is declared in a package such as, then you must use the full classname including the package name in the java command e.g. the right class name, but in the wrong form.) Considering the example above, here a variety of wrong ways to specify the class name:Įxample #1 - a simple class name: java ListUser The first likely cause is that you may have provided the wrong class name. So why might it be unable to find the class? Reason #1 - you made a mistake with the classname argument And indeed, the "." in the message will be the fully qualified class name that java is looking for. The java command was not able to find the class. ", that means that the first step has failed. When you get the message "Could not find or load main class. Call that method passing it the command line arguments ("fred", "joe", "bert") as a String.(Note, the method argument's name is NOT part of the signature.) Check that the class has a main method with signature, return type and modifiers given by public static void main(String).Search for the compiled version of the class.The above is going to cause the java command to do the following: Here is an example of what a java command should look like: java -Xmx100m fred joe bert

not something I just made up to confuse you :-) Note that the term fully qualified name is standard Java terminology.

Which (confusingly) looks like a file pathname, but isn't one. packagename/packagename2/packagename3/ClassName However some versions of the java command allow you to use slashes instead of periods e.g. The fully qualified name (FQN) for the class is conventionally written as you would in Java source code e.g. 1 - There is a second syntax for "executable" JAR files which I will describe at the bottom. Where is a command line option (starting with a "-" character), is a fully qualified Java class name, and is an arbitrary command line argument that gets passed to your application. What does “Could not find or load main class” mean?įirst of all, you need to understand the correct way to launch a program using the java (or javaw) command.
