- Download the 3 JavaFX jar files:
javafxrt.jar
Filters.jar
swing-layout.jar
You can get them from here:
https://openjfx.dev.java.net/source/browse/openjfx/trunk/lib/ - Create a text file called
Hello.fx
:import javafx.ui.*; Frame { content: Label { text: "Hello JavaFX" } visible: true }
- Add the 3 jars and Hello.fx to your classpath
- Run the script like so:
java net.java.javafx.FXShell Hello
Note: The nameHello
is resolved via the classpath (not the file system).
Here is how my folders looked:
~/DavesJavafxDemo/classes/Hello.fx
~/DavesJavafxDemo/lib/javafxrt.jar
~/DavesJavafxDemo/lib/Filters.jar
~/DavesJavafxDemo/lib/swing-layout.jar
Thus, my classpath must include the classes folder plus the 3 jar files:
~/DavesJavafxDemo/classes
~/DavesJavafxDemo/lib/javafxrt.jar
~/DavesJavafxDemo/lib/Filters.jar
~/DavesJavafxDemo/lib/swing-layout.jar
Here is the shell script I used:cp=./lib/swing-layout.jar:./lib/Filter.jar:./lib/javafxrt.jar:./classes java -classpath $cp net.java.javafx.FXShell Hello
Note: The way I have the paths specified, you must run this script from within DavesJavafxDemo folder.
On Windows, the shell script (runDemo.bat) would look like this:set cp=.\lib\swing-layout.jar;.\lib\Filter.jar;.\lib\javafxrt.jar;.\classes java -classpath %cp% net.java.javafx.FXShell Hello
Wednesday, June 27, 2007
Minimal JavaFX Demo
Here are the absolute simplest steps to get a demo of JavaFX up an running:
Subscribe to:
Post Comments (Atom)
3 comments:
Dave,
I don't understand the goal of JavaFX. As a Flash alternative seems limited... JavaFX is not offered as a plug-in (as Flash), and I don't know if it can run as an applet.
On the other hand, how good it is for application development? I have a portal and I would love to put JavaFX on it, but I'm not sure if it would be better than using Flash-oriented tools, such as Laszlo.
Is there a place for JavaFX?
Luis
This is cool stuff, Dave. I hope to make your talk tonight.
Your blog keeps getting better and better! Your older articles are not as good as newer ones you have a lot more creativity and originality now keep it up!
Post a Comment