Question: I have a Java book and im trying to learn obviously Java Programming.

I have a lesson that tells me simply to put this Code on Eclipse.

I copied from the Book and i put it on Eclipse program that i test and learn there. When i run it, it doesn't says any error. But at the moment that i run it, it shows me this error:

[Code on Eclipse](https://i.stack.imgur.com/Zw2Va.jpg)

[Code on the Book](https://i.stack.imgur.com/tQZcv.jpg)

Does anyone knows what happens here? Is the book wrong or what?

Thanks.

Answer: 
You have to write the main method as suggested by the compiler here. When you run a Java Program, the JVm searches for the main method in the class. There is no main method defined in this case, so it is giving this error.

```
public static void main(String[] args){
 new GradeBook().displayMessage();
}

```

Add the above code snippet to your class and run it. It will work.
To learn more about main method in Java check this link
[Java Main Method](http://tutorials.jenkov.com/java/main-method.html)
You need to add `main` method to your `class` and call `displayMessage()` in it : 

```
class GradeBook {

    public void displayMessage() {
        System.out.println("something");
    }

    public static void main(String[] args) {
        new GradeBook().displayMessage();
    }
}

```