• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

no main method found

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting an error message stating I have no main when I run. It compiles OK. I have a main but it says I dont. Thanks ahead of time for any help.


 
Bartender
Posts: 4568
9
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JVM is looking for a method public static void main (String[]) - exactly. You're missing a word.
 
Tom Orr
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK so I have started over and this is what I have. I now need to know how to create an object of Dice with Die1 and Die2.
would I just start with
Dice Die1 = new Dice();
Dice Die2 = new Dice();

Here is where I would need to assign the value to Die1 and Die2 for the setUpperFace and Im not sure how to do that.


 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I must admit, I'm a bit confused as to exactly what you're trying to do here. Some issues:

- If you want to use new Dice(), you need a Dice class. Where is it?

- If the Die2 class is supposed to represent a die, so that you can create several of them, then why are all the methods static? The class should have a non-static state (a private int upperFace would be fine), and then I'd expect most of the methods to refer to that state.

- You have (twice) declared UpperFace as a method-local variable, but then you're trying to refer to it in getUpperCase(). It's not visible there.

- You aren't consistent with your use of capitalisation. Following Java conventions, methods and variables should start with a lower-case letter

Here's one way of defining a simple Die class that could be used by your main class:
 
Tom Orr
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes I realize I am not understanding this very well. Thanks for your help. I am hoping that things start clicking for me soon.

Here is what I have after the suggestions. Still now working as I expected. If you could point out my errors again I will keep trying.

 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think the main method issue is resolved. Please continue the other logic questions in this parallel thread...

https://coderanch.com/t/533914/java/java/Variables-assigned-objects
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic