Java Reference
In-Depth Information
See also
F Building and packaging your app with an IDE
F Building and packaging your app with javafxpackager
F Packaging your app to be Web Start(ed)
Passing arguments to JavaFX applications
Often, it is desirable to pass in parameterized values as arguments to a running application.
In regular Java applications, for instance, this is done by passing arguments through the
command-line when an application is launched. This recipe shows you how to inject both
application parameters and VM-level parameters into a desktop JavaFX application launched
with the Web Start application.
Getting ready
This recipe shows how to pass in both applications and VM arguments to a JNLP-launched
application via the Web Start or the new Java Plugin. If you are not familiar with JNLP, review
the previous recipes Building and packaging your app with javafxpackager , Packaging your
app to Be Web Start(ed) , and Packaging your app as an applet .
For this recipe, we will create a simple JavaFX application, which reads a parameter value
passed in as an argument and displays it on stage. Simple, right? Right! Let's see how to do it.
How to do it...
1. To get started, we create a simple application that makes use of runtime parameters.
The application will display a greeting, using a name passed in as a parameter.
The full listing of the code can be found at ch07/source-code/src/params/
RuntimeArgsApplet.fx .
var name = FX.getArgument("name");
var msg:Text = Text {
font : Font {
size : 52 embolden: true
name: "sans-serif,Arial,Helvetica"
content: bind "Hello {name}!" fill:Color.WHITE
msg.translateY = msg.boundsInLocal.height;
Stage {
title: "Application title"
Search WWH ::

Custom Search