Exception in Application constructor
<p>I wanna write a Snake game with javaFX , but there is exception that I don't know about and I want to know how to fix it. ( i know it's not complete yet ) </p>

<p>and I want to know , the class that extends Application ( with start override )
is exactly the main in other programs? 
as you see , here is not static void main BC I didn't need, but if i want to add main where shoud i do?</p>

<p>it's the Exeption...</p>

<pre><code> Exception in Application constructor
Exception in thread "main" java.lang.NoSuchMethodException: Main_Snake.main([Ljava.lang.String;)
    at java.lang.Class.getMethod(Class.java:1819)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:125)
</code></pre>

<p>and my code is :</p>

<pre><code>import javafx.animation.AnimationTimer;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.BorderPane;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

import java.util.ArrayList;

/**
 * Created by Nadia on 1/5/2016.
 */



public class Main_Snake extends Application{
    Snake snake = new Snake();
    Apple apple = new Apple();

    Canvas canvas = new Canvas(800, 600);
    boolean goNorth = true, goSouth, goWest, goEast;
    int x, y = 0; // marbut be apple
    boolean j = false;
    //    int gm_ov = 0; // vase game over shodan
    ArrayList&lt;Integer&gt; X = new ArrayList&lt;Integer&gt;();
    ArrayList&lt;Integer&gt; Y = new ArrayList&lt;&gt;();


    @Override
    public void start(Stage primaryStage) throws Exception {

        BorderPane b = new BorderPane(canvas);
        Scene scene = new Scene(b, 800, 600);
        primaryStage.setScene(scene);
        primaryStage.show();

        //KeyBoard(scene);

        scene.setOnKeyPressed(new EventHandler&lt;KeyEvent&gt;() {
            @Override
            public void handle(KeyEvent e) {
                switch (e.getText()) {
                    case "w":
                        if (!goSouth) {
                            goNorth = true;
                            goSouth = false;
                            goWest = false;
                            goEast = false;
                        }
                        break;
                    case "s":
                        if (!goNorth) {
                            goSouth = true;
                            goNorth = false;
                            goWest = false;
                            goEast = false;
                        }
                        break;
                    case "a":
                        if (!goEast) {
                            goWest = true;
                            goEast = false;
                            goSouth = false;
                            goNorth = false;
                        }
                        break;
                    case "d":
                        if (!goWest) {
                            goEast = true;
                            goWest = false;
                            goSouth = false;
                            goNorth = false;
                        }
                        break;

                }
            }
        });


        play();
    }

    public void play(){
        AnimationTimer timer = new AnimationTimer() {


            private long lastUpdate = 0;

            @Override
            public void handle(long now) {

                if (now - lastUpdate &gt;= 40_000_000) {  // payin avordane sor@

                    snake.pos_S(); // har bar mar rasm mishe bad az move va ye sib ba X,Y khodesh rasm mishe tu tabe move dar morede tabe Point hast
                    apple.pos_A();
                    apple.random_Pos();
                    snake.Move();

                    lastUpdate = now; // sor@
                }

            }
        };

        timer.start();

    }
   /* public void KeyBoard(Scene scene) {
    }*/
}

 class Apple extends Main_Snake {


     public void random_Pos() {
         if (j == false) { // ye sib bede ke ru mar nabashe ( rasmesh tu rasme )
             do {
                 x = (int) (Math.random() * 790 + 1);
                 y = (int) (Math.random() * 590 + 1);
             } while (X.indexOf(x) != -1 &amp;&amp; Y.get(X.indexOf(x)) == y || x % 10 != 0 || y % 10 != 0);
                        /*inja aval chek kardam tu araylist x hast ya na ag bud sharte aval ok hala sharte do ke tu Y ham mibinim tu hamun shomare khune
                        y barabare y mast ag bud pas ina bar ham montabeghan va sharte dovom ham ok . 2 sharte akhar ham vase ine ke mare ma faghat mazrab
                        haye 10 and pas ta vaghti in se shart bargharare jahayie ke ma nemikhaym va hey jaye dg mide*/

             j = true;
         }

     }

     public void pos_A() {
         GraphicsContext gc = canvas.getGraphicsContext2D();
         gc.setFill(Color.BLACK);
         gc.fillRect(x, y, 10, 10);

     }

     public void Point() {
         if (X.get(0) == x &amp;&amp; Y.get(0) == y) {
             j = false;
         }
     }
 }


 class Snake extends Main_Snake {
    Snake(){   //cunstructor

        X.add(400);
        Y.add(300);

        X.add(400);
        Y.add(310);

        X.add(400);
        Y.add(320);


        X.add(400);
        Y.add(330);


        X.add(400);
        Y.add(340);
    }

    public void pos_S(){
        GraphicsContext gc = canvas.getGraphicsContext2D();
        gc.setFill(Color.WHITE);
        gc.fillRect(0, 0, canvas.getWidth(), canvas.getHeight());
        apple.pos_A();

        // keshidane mar (body yeki ezafe tar az adade morabaA mide)
        for (int i = X.size() - 1; i &gt;= 0; i--)
            gc.fillRect(X.get(i), Y.get(i), 10, 10);

    }
    public void Move(){

        int Px = X.get(X.size() - 1);
        int Py = Y.get(Y.size() - 1);

        for (int z = X.size() - 1 ; z &gt; 0 ; z--){
            X.remove(z);
            X.add(z , X.get(z-1) )   ;
            Y.remove(z);
            Y.add(z , Y.get(z-1) )   ;

        }

        if (goNorth) {
            Y.add(0 , Y.get(0) - 10);
            Y.remove(1);

        }
        if (goSouth) {
            Y.add(0 , Y.get(0) + 10);
            Y.remove(1);

        }
        if (goEast)  {
            X.add(0 , X.get(0) + 10);
            X.remove(1);

        }
        if (goWest)  {
            X.add(0 , X.get(0) - 10);
            X.remove(1);

        }

        apple.Point();        // emtiaz gerefte
        if ( j == false)    {
            X.add(Px);
            Y.add(Py);
        }

        if ( X.get(0) &gt; 790 ){
            X.remove(0);
            X.add(0 , 0);
        }
        if ( X.get(0) &lt;  0  ){
            X.remove(0);
            X.add(0 , 800);
        }
        if ( Y.get(0) &gt; 590 ){
            Y.remove(0);
            Y.add(0 , 0);
        }
        if ( Y.get(0) &lt;  0  ){
            Y.remove(0);
            Y.add(0 , 600);
        }

    }
}
</code></pre>