Begin the game development with JavaFx in Eclipse Oxygen

Welcome to the first chapter of the game development with JavaFx series, if you are new here then I just want to let you know that starting from this week I will post two articles about the game development with JavaFx in this blog every week with the full source code included inside the article. The game I am creating is a new game which is created only for this JavaFx gaming tutorial series and I do hope you will like it.

In the first chapter of this JavaFx gaming development we are going to create a simple user interface with the JavaFx library. We will use eclipse oxygen ide to develop our JavaFx gaming development project so if you have not yet downloaded eclipse oxygen then you can download it’s installer and from there you can then install the Eclipse Java Oxygen IDE for your game development.

Besides eclipse oxygen you also need to have Java 8 installed in your computer system and if you have already downloaded the Java 8 SDK then you should also already have installed the JavaFx library as well which comes together with the same download so there is no need to further download JavaFx library separately anymore in order for you to develop game with JavaFx. However you still need to download the JavaFx tooling and runtime plugin for Eclipse Oxygen before you can start to develop your JavaFx desktop gaming application, under the eclipse oxygen’s header go to Help->Eclipse Marketplace then type in e(fx)clipse to the search box to download the only plugin which you ever need for the JavaFx development in eclipse oxygen.

With that sattle let create a brand new project in eclipse oxygen. Goto File->New->Java Project. Fill in the project name then click Finish.

Next create a Java project package, right create on the GamingDemo folder and then select New->Package. Provide a package name for the entire project package, the best is to turn around the url of your website to make it the name of the package. Next click Finish.

Now right click on the package and select New->Class to create a Java class. Provide the name for the class and click on the browse button beside superclass to search for JavaFx’s Application class under the Choose a type search box. Select the JavaFx Application class then click OK.

Use the New Java Class setting as shown below, make sure you have given the name for that class and click Finish.

Now the class has been generated, under the two methods of that class fill in below code, don’t worry about the code, the main mission here is just to create our first project in eclipse oxygen and set up the JavaFx library for future development, we will come back to the code explanation part on the next chapter. If you see any red line below the code just hover it then click to import the necessary javafx’s class which it needs.

package info.codingdirectional;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class GamingDemo extends Application {
	private double CANVAS_WIDTH = 600;
	private double CANVAS_HEIGHT = 600;

	public void start(Stage stage) throws Exception {
		StackPane root = new StackPane();
		Scene theScene = new Scene( root, CANVAS_WIDTH, CANVAS_HEIGHT);
		stage.setTitle( "Empty Game Scene" );;


	public static void main(String[] args) {


Now click on the green arrow button on the eclipse oxygen header to compile and then run the code.

That is it, we have succeed creating our first JavaFx project, in the next chapter we will talk about the storyline and the layout of our new game, then in the next next chapter we will start coding.

Leave a Reply

Your email address will not be published. Required fields are marked *