### Example Hello (non-Eclipse)

Example of simple Hello type app.
Java Source HelloJavaFX.java
package hellojavafx;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class HelloJavaFX extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("JavaFX Example App");
primaryStage.initStyle(StageStyle.UTILITY);
StackPane root = new StackPane();
root.setStyle("-fx-background-color: red");
final Scene scene = new Scene(root, 400, 300);
Label lbl = new Label();
lbl.setStyle("-fx-border-color:red; -fx-background-color: blue; -fx-text-fill: white; -fx-font-weight: bold;");
lbl.setFont(Font.font(java.awt.Font.SERIF, 42));
lbl.setText("Hello JavaFX");
root.getChildren().add(lbl);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Batch to create JAR file hellojavafx.jar
@Echo Off
@Echo Off
REM JavaFX Java Development - Creating executable Jar for Project HelloJavaFX (Package hellojavafx, Class HelloJavaFX)
REM Folder Structure:
REM Source: c:\Daten\java\JavaFX\Apps\HelloJavaFX\
REM Class: c:\Daten\java\JavaFX\Apps\HelloJavaFX\hellojavafx
REM Jar: c:\Daten\java\JavaFX\Apps\HelloJavaFX\jar
REM
REM This batch is run from Folder c:\Daten\java\JavaFX\Apps\HelloJavaFX
REM
@Echo JavaFX Example Project HelloJavaFX
REM
@Echo Set Project Source Folder
cd c:\Daten\java\JavaFX\Apps\HelloJavaFX\
dir /b *.java
REM
@Echo Compile Java Class in Folder hellojavafx
"c:\Program Files (x86)\Java\jdk8\bin\javac.exe" -d . HelloJavaFX.java
dir /b hellojavafx\*.class
REM
@Echo Create JAR in Folder jar
"c:\Program Files (x86)\Java\jdk8\bin\javapackager.exe" -createjar -appclass hellojavafx.HelloJavaFX -srcdir . -outdir jar -outfile hellojavafx.jar -v
dir /b jar\*.jar
REM
@Echo Run JAR located in folder jar from the Project folder
"c:\Program Files (x86)\Java\jdk8\bin\javaw.exe" -jar jar/hellojavafx.jar
REM
@Echo Done ...
Pause

Changed: , Category: JavaFX Java Development, File: T6C207M1513.htm, ID: 1513