File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

no main method found

 
Tom Orr
Greenhorn
Posts: 13
  • 0
  • Mark post as helpful
  • send pies
  • 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.


 
Matthew Brown
Bartender
Posts: 4549
8
Java Netbeans IDE Scala
  • 2
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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: 4549
8
Java Netbeans IDE Scala
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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.

 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the main method issue is resolved. Please continue the other logic questions in this parallel thread...

http://www.coderanch.com/t/533914/java/java/Variables-assigned-objects
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic