Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Exception in thread "main" java.lang.NoSuchMethodError: main?

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Exception in thread "main" java.lang.NoSuchMethodError: main?

    Hello Friends,

    I am beginner of java.
    here i am facing run time exception for code
    snippet which i am pasting here,please help me on this issue.

     
    class Operation
    {
    int square(int n)
    {
    return n*n;
    }
    }
     
     
    class Circle
    {
    Operation op;
    double pi=3.14;
     
    double area(int radius)
    {
    op=new Operation();
    int rsquare=op.square(radius);
    return pi*rsquare;
    }
     
    public static void main(String args[])
    {
    Circle c = new Circle();
    double result = c.area(5);
     
    System.out.println(result);
    }
    }

    Regards
    Sk.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Exception in thread "main" java.lang.NoSuchMethodError: main?

    Please post the full text of the error message, and show us exactly which line is throwing the Exception (since line numbers on the forum might not be the line numbers on your machine).
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Exception in thread "main" java.lang.NoSuchMethodError: main?

    Hello,

    The problem has sorted out by my own,
    thanks for reply.
    i am facing problem in another source code here as

    class Simple2
    {
    public static void main(String args[])
    {
    String s ="Altaf";
    s.concat(" Shikalgar");
    System.out.println(s);
    }
    }

    it gives error as
    [Simple2.java:3: cannot access String
    bad class file : .\String.java
    file does not contain class String
    Please remove or make sure it appears in the correct sub directory of class path. ]

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Exception in thread "main" java.lang.NoSuchMethodError: main?

    Did you create a new class named String? If so, rename it.

    What version of Java are you running? How are you compiling this?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Replies: 1
    Last Post: April 7th, 2013, 03:40 PM
  2. Replies: 3
    Last Post: December 7th, 2011, 02:03 AM
  3. Replies: 6
    Last Post: November 12th, 2010, 04:40 AM
  4. Replies: 2
    Last Post: March 26th, 2010, 11:22 AM
  5. "java.lang.NoSuchMethodError: main" and "fatal exception occured."
    By joachim89 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 10th, 2010, 08:35 AM