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.

Page 2 of 2 FirstFirst 12
Results 26 to 31 of 31

Thread: Beginner for Java, need help with this code I wrote

  1. #26
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Beginner for Java, need help with this code I wrote

    Your IDE is executing the java command with a classname. It builds a commandline:
    java <classnamehere>
    The contents of the error message makes it look like the classname being used is: Cards$Suits
    Somewhere in the IDE you specify what classname is to be used. I have no idea how to setup your IDE so that it picks the correct classname to use.
    The classname to use should be changed to Cards.

  2. #27
    Member
    Join Date
    Feb 2012
    Location
    West USA
    Posts
    67
    My Mood
    Inspired
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Beginner for Java, need help with this code I wrote

    Oh....

    Well, it was already defined as Cards, see:

    public class Cards {
     
    	enum Suits { Club, Diamond, Spade, Heart }
     
    	    public static void main(String[] arg)  {

  3. #28
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Beginner for Java, need help with this code I wrote

    Here is an example of the use of the java command with the wrong classname and the right one:

    Microsoft Windows XP [Version 5.1.2600]
     
    D:\JavaDevelopment\Testing\ForumQuestions8>java Cards$Suits      <<<<<<<<< THE WRONG classname
    Exception in thread "main" java.lang.NoSuchMethodError: main
     
    D:\JavaDevelopment\Testing\ForumQuestions8>dir Cards*
     Volume in drive D is Work
     Volume Serial Number is 0C24-B38C
     
     Directory of D:\JavaDevelopment\Testing\ForumQuestions8
     
    02/13/2012  09:39 PM             1,024 Cards$Suits.class
    02/13/2012  09:39 PM             1,228 Cards.class
    02/13/2012  09:41 PM               996 Cards.java
                   3 File(s)          3,248 bytes
                   0 Dir(s)   7,020,515,328 bytes free
     
    D:\JavaDevelopment\Testing\ForumQuestions8>java Cards              <<<<<<<<<<< The correct classname
    I'm thinking of a suit. Can you guess what it is?You got it wrong.
    D:\JavaDevelopment\Testing\ForumQuestions8>

    The error message you are getting must be coming from your IDE.
    You'll need to ask someone why it gives that error message. The javac compiler does not give any errors when compiling your code.
    Last edited by Norm; February 14th, 2012 at 10:20 AM.

  4. #29
    Member
    Join Date
    Feb 2012
    Location
    West USA
    Posts
    67
    My Mood
    Inspired
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Beginner for Java, need help with this code I wrote

    Hmmm.......

    Alright, I just don't know who to ask.

  5. #30
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Beginner for Java, need help with this code I wrote

    The forum has an IDE section. Try asking there.
    Java IDEs

  6. #31
    Member
    Join Date
    Feb 2012
    Location
    West USA
    Posts
    67
    My Mood
    Inspired
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Re: Beginner for Java, need help with this code I wrote

    Thanks.

    -Silent

Page 2 of 2 FirstFirst 12

Similar Threads

  1. (beginner) if else code.
    By dumb1101 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: January 16th, 2012, 02:47 AM
  2. Beginner pleasee help with java code
    By chuy525 in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 24th, 2011, 06:38 PM
  3. Replies: 3
    Last Post: October 19th, 2011, 11:55 PM
  4. Beginner trying to write Java code, has issue w/ printing result and 2 decimals
    By flpanthers1 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 5th, 2011, 11:11 AM
  5. Beginner - Help with my code.
    By eddross in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 12th, 2010, 09:30 AM