theasianmamba24 theasianmamba24 - 1 year ago 66
Java Question

"Could not find or load main class [Class name]"

I pasted this code from a tutorial site and compiled the code in CMD as well as attempting to run the code:

public class ExampleProgram {
public static void main(String[ ] args) {
System.out.println("Hello World");

Since the PATH variable already existed, I added a path to the 'bin' file within the java file. I also added a new variable (CLASSPATH) and set the variable value to where I keep the


  • The
    and the
    file are in the same folder

  • No spelling or capitalization errors are made

  • I did not add
    at the end where I try to run the code

Answer Source

Assuming that you have you java path set up done coorectly, run the following commands in order : JavaProg is the name of the java file and your public class.

1.Suppose my .java file is in Desktop, then run the following command

cd Desktop

2. Compile it


3. Run it

java JavaProg
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download