JavaFx: Hello World

In this tutorial we will print the customary "Hello World" to console and the the GUI using JavaFX.



  • First we have to create a new Module (new application)
  • select Maven app






Type in group ID "edu.clc.cit137"
Type in artifact ID "javafx-hello"







Create a NEW Java Class (or File) named "HelloWorld.java"





Analyze the simple GUI in the image below.

Please type all Java code, click on the image to enlarge full screen.



In the second part of the code we have an EVENT handler for the BUTTON.
And layout of the widgets using HBox and VBox.



Finally, notice that package says "helloworld", however we are not in that package. Control click (command 1) on RED underline until options show up, select "Move to package..."



Run the app






As an Amazon Associate I earn from qualifying purchases.

My favorite quotations..


“A man should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.”  by Robert A. Heinlein

"We are but habits and memories we chose to carry along." ~ Uki D. Lucas


Popular Recent Articles