Results 1 to 4 of 4
  1. #1
    vickyv200 is offline Member
    Join Date
    Aug 2012
    Posts
    6
    Rep Power
    0

    Default Error:Could Not Find or Load Main Class

    I can clearly see the .class file in my java folder.
    I type in java (FILE NAME) in the windows command prompt, I get the error: Could not find or load main class.
    I got the .class file from typing in, javac (FILE NAME)

    Please tell me what is wrong. If you need a copy of my code please tell me.
    Last edited by vickyv200; 08-27-2012 at 10:19 PM.

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    6

    Default Re: Error:Could Not Find or Load Main Class

    Quote Originally Posted by vickyv200 View Post
    I type in java (FILE NAME) in the windows command prompt,
    with file extension? if so, that's your fault

    Quote Originally Posted by vickyv200 View Post
    I get the error: Could not find or load main class.
    code?
    full error message?
    .....

  3. #3
    vickyv200 is offline Member
    Join Date
    Aug 2012
    Posts
    6
    Rep Power
    0

    Default Re: Error:Could Not Find or Load Main Class

    Quote Originally Posted by eRaaaa View Post
    with file extension? if so, that's your fault


    code?
    full error message?
    .....
    Yes, the file is a .java file, no I do not type .java. I am able to run the code when I use java -cp . FILENAME but not java. This applies to everything I have made, here is an example.

    public class test{
    public static void main(String[] args) {
    System.out.println("test");
    }
    }

    The full error message is Error:Could Not Find or Load Main Class test
    Last edited by vickyv200; 08-27-2012 at 10:47 PM.

  4. #4
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: Error:Could Not Find or Load Main Class

    Well, your code sample works for me.

    Some notes:
    1. Make sure your class names start with a capital letter, as java code convention dictates
    2. Java is case sensitive, so the name of the class and the actual java file must be the same:
    Java Code:
    public class Test{ 
        //...
    and
    Test.java

    These must match exactly. Once you compile with javac, you should get Test.class. Run this with:
    java Test

    You also must make sure that when you run the file, you are in the same folder (or the top level of your package tree if using packages!)

Similar Threads

  1. 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
  2. Error: Could not find or load main class HelloWorld
    By grejsimojs in forum New To Java
    Replies: 8
    Last Post: 07-11-2012, 10:27 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
  •