File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes no main method found Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "no main method found" Watch "no main method found" New topic
Author

no main method found

Tom Orr
Greenhorn

Joined: Mar 17, 2011
Posts: 13
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

Joined: Apr 06, 2010
Posts: 4343
    
    8

The JVM is looking for a method public static void main (String[]) - exactly. You're missing a word.
Tom Orr
Greenhorn

Joined: Mar 17, 2011
Posts: 13
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

Joined: Apr 06, 2010
Posts: 4343
    
    8

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

Joined: Mar 17, 2011
Posts: 13
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

Joined: Aug 31, 2004
Posts: 11343

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


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: no main method found
 
Similar Threads
While Loop Error
Need Help Understand this.
Variables assigned to objects
Need help ending number guessing game and asking if user wants to play again
Create a Die Class