Results 1 to 9 of 9
  1. #1
    gullar is offline Member
    Join Date
    Feb 2012
    Posts
    4
    Rep Power
    0

    Default Need Help please

    Ok, i am VERY new to java and any type of programming,
    After making a hello world application i wanted to do something with variables.
    i got the basic code and adapted it so terminal would compile it. here it is

    public class VariableTest {

    public VariableTest() {
    int first, second;
    first = 1;
    second = 2;

    System.out.println ("a is " + first); // 's' in system must be capital
    }//end of class

    } //end of program


    so i compiled it in terminal then i tried running it with "java VariableTest" to which terminal replies

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

    and it didnt run my program, can someone tell me what i need to do to fix this?
    thanks for reading
    ollie
    PS i use mac by the way

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

    Default Re: Need Help please

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

  3. #3
    gullar is offline Member
    Join Date
    Feb 2012
    Posts
    4
    Rep Power
    0

    Default Re: Need Help please

    what? this does not answer my request.

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

    Default Re: Need Help please

    Quote Originally Posted by gullar View Post
    what? this does not answer my request.
    If that doesn't, nothing will. Or did you expect someone here to do your homework for you?

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

  5. #5
    gullar is offline Member
    Join Date
    Feb 2012
    Posts
    4
    Rep Power
    0

    Default Re: Need Help please

    nope, i just expected someone to be nice, and point out my mistake. Not provide me with a link as helpful as saying 'google.com'

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Need Help please

    Quote Originally Posted by gullar View Post
    nope, i just expected someone to be nice, and point out my mistake. Not provide me with a link as helpful as saying 'google.com'
    The tutorial *will* show you what you're doing wrong. You can debate this here or you can look at the link. For my money, I'd choose the latter.

  7. #7
    gullar is offline Member
    Join Date
    Feb 2012
    Posts
    4
    Rep Power
    0

    Default Re: Need Help please

    ok, now terminla says:
    VariableTest.java:2: missing method body, or declare abstract
    public static void main(String[] args);
    ^
    1 error

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Need Help please

    Have re-look at that tutorial as that's not how you write a main method. Note that every part has to be perfect as the compiler is very picky. This includes semicolons.

  9. #9
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Location
    Turkey
    Posts
    380
    Blog Entries
    24
    Rep Power
    3

    Default Re: Need Help please

    i tried running it with "java VariableTest"
    When you try running it with java VariableTest, Java tries to run the method main in VariableTest. Since you do not have a main method, Java tells you:
    Exception in thread "main" java.lang.NoSuchMethodError: main
    Does this help you ?

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
  •