Results 1 to 6 of 6
  1. #1
    tedjava is offline Member
    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Default could not find or load main class HelloWorldExample

    Plz help
    I have set the (user variable for owner)path correctly ie (C:\Program Files\Java\jdk1.7.0_09\bin;)


    I have altered the system variable class path. i wonder if that is why my program is not locating the main class.
    i deleted some stuff then added........or messed it up.
    now it is C:\Program Files\Java\jdk1.7.0_09\lib

    i do not know how the class path should be
    even the command java -cp . HelloWorldExample works but not java HelloWorldExample
    (code compiles but dosent excecute)
    my working directry is c:\javaprograms> where i have stored the HelloWorldExample.java code and the class file also is in the same folder.


    my code is

    public class HelloWorldExample{

    public static void main(String args[]){


    System.out.println("Hello World !");




    }

    }

  2. #2
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default Re: could not find or load main class HelloWorldExample

    You can just run your HelloWorldExample by executing command java HelloWorldExample. Just make sure that java command is executable from your command line.

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: could not find or load main class HelloWorldExample

    Moved from a staff only section.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,242
    Rep Power
    19

    Default Re: could not find or load main class HelloWorldExample

    Quote Originally Posted by wsaryada View Post
    You can just run your HelloWorldExample by executing command java HelloWorldExample. Just make sure that java command is executable from your command line.
    The "Could not find or load main class" error comes from the Java executable.

    The real issue is that a system CLASSPATH is set, one that does not include the current working directory. tafjava, either get rid of the system CLASSPATH (prefereable) or prepend ".;" to it.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    tedjava is offline Member
    Join Date
    Dec 2012
    Posts
    2
    Rep Power
    0

    Default Re: could not find or load main class HelloWorldExample

    Quote Originally Posted by wsaryada View Post
    You can just run your HelloWorldExample by executing command java HelloWorldExample. Just make sure that java command is executable from your command line.



    Am not able to excecute the command " java HelloWorldExample " from the command prompt

    this is what gives me the error "could not find or load main class HelloWorldExample"

    don't know what to do?

  6. #6
    wsaryada is offline Senior Member
    Join Date
    Jun 2007
    Location
    Bali, Indonesia
    Posts
    760
    Rep Power
    8

    Default Re: could not find or load main class HelloWorldExample

    Just as DB pointed out in his post earlier. You should remove your system classpath. You can see the current value of classpath using the echo %CLASSPATH% from you command prompt. Then execute it again using java -cp . HelloWorldExample.

Similar Threads

  1. Replies: 1
    Last Post: 11-29-2012, 09:46 AM
  2. Could not find or load main class
    By kkid in forum New To Java
    Replies: 4
    Last Post: 10-15-2012, 04:47 AM
  3. 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
  4. Error: Could not find or load main class
    By Tybald in forum Eclipse
    Replies: 5
    Last Post: 05-28-2012, 11:22 AM
  5. Replies: 3
    Last Post: 12-09-2011, 03:51 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
  •