Results 1 to 5 of 5
  1. #1
    kkid is offline Senior Member
    Join Date
    Jul 2012
    Posts
    226
    Rep Power
    2

    Default Could not find or load main class

    I come across this occasionally, what causes it?

  2. #2
    killutch is offline Member
    Join Date
    Sep 2012
    Posts
    70
    Rep Power
    0

    Default Re: Could not find or load main class

    Quote Originally Posted by kkid View Post
    I come across this occasionally, what causes it?
    you must have a class that looks like the following

    Java Code:
    public static void main(String[] args){
    
    }
    this is always the method that is run after you compile your program. There are a few exceptions but from what i know. One way or another this is satisfied somewhere.

    ---edit---
    after I compile with no main method this isn't the error I get. So sorry if this doesn't help you.
    Last edited by killutch; 10-13-2012 at 06:05 PM.

  3. #3
    Join Date
    Mar 2011
    Posts
    93
    Rep Power
    0

    Default Re: Could not find or load main class

    Hello.

    A couple of things:
    1) did you mis-type or mis-spell your class name? I always first check my spelling and look for typos
    2) did you save the class is the wrong location? If you are using command prompt, be sure to navigate to the folder that holds your class.

    If you give us the full error message you are getting, and more details when you get the error message, people here can better pinpoint the problem(s).

  4. #4
    kkid is offline Senior Member
    Join Date
    Jul 2012
    Posts
    226
    Rep Power
    2

    Default Re: Could not find or load main class

    Quote Originally Posted by killutch View Post
    you must have a class that looks like the following

    Java Code:
    public static void main(String[] args){
    
    }
    this is always the method that is run after you compile your program. There are a few exceptions but from what i know. One way or another this is satisfied somewhere.

    ---edit---
    after I compile with no main method this isn't the error I get. So sorry if this doesn't help you.
    isn't that a method, not a class?


    Quote Originally Posted by Humphrey Bogart View Post
    Hello.

    A couple of things:
    1) did you mis-type or mis-spell your class name? I always first check my spelling and look for typos
    2) did you save the class is the wrong location? If you are using command prompt, be sure to navigate to the folder that holds your class.

    If you give us the full error message you are getting, and more details when you get the error message, people here can better pinpoint the problem(s).
    What do you mean misspelling the class name? I thought I could call it anything.

  5. #5
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default Re: Could not find or load main class

    Remember that Java is case sensitive. If you place a class hello inside a file called Hello.java (which is perfectly legal) and try to run "java Hello" you will get that message as Hello.java does not have a main method.

Similar Threads

  1. Error:Could Not Find or Load Main Class
    By vickyv200 in forum New To Java
    Replies: 3
    Last Post: 08-29-2012, 01:10 AM
  2. Error: could not find or load main class
    By sloppygecko in forum New To Java
    Replies: 3
    Last Post: 08-08-2012, 03:11 PM
  3. Error: Could not find or load main class
    By Tybald in forum Eclipse
    Replies: 5
    Last Post: 05-28-2012, 11:22 AM
  4. Replies: 3
    Last Post: 12-09-2011, 03:51 AM
  5. Error: Could not find or load main class
    By ITSlave in forum New To Java
    Replies: 4
    Last Post: 09-15-2011, 09:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •