Results 1 to 6 of 6
  1. #1
    singularity is offline Member
    Join Date
    Sep 2009
    Posts
    14
    Rep Power
    0

    Default Fatal Exception, Program will exit(pop up)

    While running the following code in eclipse, I get the following error:


    java.lang.NoSuchMethodError: main
    Exception in thread "main"
    I am sure something is wrong with the Eclipse settings, Please see where I am going wrong.

    Java Code:
    package package1;
    
    public class Largest {
    	public static void main(String args) {
    		int arr[] ={1,2,3};
    		int temp=0;
    		for(int i =0;i<arr.length;i++) {
    			if(arr[i] > arr[i+1]) {
    				temp=arr[i];
    				arr[i]=arr[i+1];
    				arr[i+1]=temp;
    			}
    		}
    		System.out.println(temp);
    	}
    
    }
    btw I have a lot of java files in my package1. I tried putting them in comments or deleting them, but it is not working.

    Thanks for the help.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,734
    Blog Entries
    7
    Rep Power
    21

    Default

    The main( ... ) method accepts an array of Strings, so:

    Java Code:
    public static void main(String[] args) {
       ...
    }
    kind regards,

    Jos

  3. #3
    singularity is offline Member
    Join Date
    Sep 2009
    Posts
    14
    Rep Power
    0

    Default

    Thanks, It was actually a typo on my part.

    My Bad!!!!!!!!!

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

    Default

    If you are satisfied with Jos comment, please mark the thread solved. It's really helpful to all other members as well.

  5. #5
    singularity is offline Member
    Join Date
    Sep 2009
    Posts
    14
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    If you are satisfied with Jos comment, please mark the thread solved. It's really helpful to all other members as well.
    Surely I will

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,371
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Could not find the main class, program will exit.
    By aryubi in forum New To Java
    Replies: 39
    Last Post: 02-19-2010, 11:02 AM
  2. Could not find the main class. Program will exit.
    By XSROSSITER in forum New To Java
    Replies: 0
    Last Post: 01-30-2010, 05:17 AM
  3. How to exit the program by typing "exit"?
    By Laythe in forum New To Java
    Replies: 6
    Last Post: 08-19-2009, 09:32 PM
  4. Could not find the main class. Program will exit.
    By Carrier in forum New To Java
    Replies: 1
    Last Post: 04-22-2009, 03:27 AM
  5. How to exit the program..
    By coco in forum New To Java
    Replies: 1
    Last Post: 08-01-2007, 06:56 PM

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
  •