Results 1 to 2 of 2
  1. #1
    RudeOil is offline Member
    Join Date
    Oct 2011
    Posts
    2
    Rep Power
    0

    Default Could not find the main class

    Hey guys...new to Java so sorry if this is a stupid question.

    OS: Windows 7
    Code:

    Java Code:
    class Ex1
    {
    	public static void main ( String [] args )
    	{
    		// Set n to be user defined input
    		int n = Integer.parseInt(args[0]);
    		
    		// Loop through n and print required sequence
    		for (int i = 0; i < n; i++)
    		{
    			System.out.print(i+1);			// n
    			System.out.print((i+1)^2);		// n^2
    			System.out.print((i+1)^3);		// n^3 
    		}	
    	}
    }
    In CMD I'm typing:

    javac ex1.java

    which creates the class in the same folder as ex1.java, then:

    java -cp . ex1_1 4

    but I get the error: "Could not find or load main class"

    Any ideas? Thx for any help :)
    Last edited by RudeOil; 10-13-2011 at 09:36 PM.

  2. #2
    RudeOil is offline Member
    Join Date
    Oct 2011
    Posts
    2
    Rep Power
    0

    Default Re: Could not find the main class

    Actually don't worry..have just solved it! Feel free to delete...

    My code should have been java -cp. ex1 4, as opposed to ex1_1!

Similar Threads

  1. Could not find or load main class BubbleSort.class
    By blaqkout in forum New To Java
    Replies: 5
    Last Post: 09-12-2011, 07:54 PM
  2. Could not find main class
    By Karenthian in forum New To Java
    Replies: 7
    Last Post: 03-30-2011, 03:02 PM
  3. Could Not Find Main Class (AGAIN!)
    By illjavathat in forum New To Java
    Replies: 54
    Last Post: 10-22-2010, 03:22 AM
  4. Could not find main class
    By Andyj in forum New To Java
    Replies: 2
    Last Post: 10-06-2009, 12:47 AM
  5. Could not find main class - JDK 1.6
    By Syranno in forum New To Java
    Replies: 1
    Last Post: 07-25-2008, 04:07 PM

Posting Permissions

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