Results 1 to 5 of 5
Like Tree2Likes
  • 1 Post By DarrylBurke
  • 1 Post By DarrylBurke

Thread: Could not find the main class, program will exit. how to solve this problem

  1. #1
    Fatz is offline Member
    Join Date
    May 2012
    Posts
    12
    Rep Power
    0

    Default Could not find the main class, program will exit. how to solve this problem

    Hi, im trying to compile my programs using the command prompt on windows 7
    im having a problem when i try compiling. i created a test program for this.

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

    i use the following instructions in my cmd
    cd \
    cd work
    Javac test.java
    java test

    I get the message "Could not find the main class, program will exit."

    I have even tried using javaw and i get the same message but on a pop-u box "Could not find the main class, program will exit."

    Could someone help please. Suggest something.
    Thanks in advance

  2. #2
    awinston is offline Student
    Join Date
    Jul 2012
    Location
    United States
    Posts
    328
    Rep Power
    3

    Default Re: Could not find the main class, program will exit. how to solve this problem

    Did you actually type Javac or did you just make a typo in your post?
    "Success is not final, failure is not fatal: it is the courage to continue that counts." - Winston Churchill

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

    Default Re: Could not find the main class, program will exit. how to solve this problem

    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,234
    Rep Power
    19

    Default Re: Could not find the main class, program will exit. how to solve this problem

    Quote Originally Posted by awinston View Post
    Did you actually type Javac or did you just make a typo in your post?
    Windows isn't case sensitive wrto file names

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

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

    Default Re: Could not find the main class, program will exit. how to solve this problem

    Try
    Java Code:
    java -cp . test
    Note there's a space-dot-space between -cp and test.

    And learn the Java coding conventions: class names begin with an uppercase letter.
    Code Conventions for the Java Programming Language: Contents
    Tolls likes this.
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Replies: 4
    Last Post: 05-28-2011, 07:29 PM
  2. Could not find the main class, program will exit.
    By CourseLanguage in forum New To Java
    Replies: 18
    Last Post: 05-03-2011, 10:14 PM
  3. Could not find the main class, program will exit
    By grottesco in forum New To Java
    Replies: 7
    Last Post: 11-03-2010, 06:51 AM
  4. Could not find the main class, program will exit.
    By aryubi in forum New To Java
    Replies: 39
    Last Post: 02-19-2010, 10:02 AM
  5. Could not find the main class. Program will exit.
    By XSROSSITER in forum New To Java
    Replies: 0
    Last Post: 01-30-2010, 04:17 AM

Tags for this Thread

Posting Permissions

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