|
SYS-CON Magazines
|
Top Linux Links You Must Click On
JavaFX Developing Your First Compiled JavaFX Script Program
CompiledHelloJavaFX
By: James L. Weaver
Nov. 24, 2007 06:45 AM
To help prepare you for the Puzzler, I'd like to you to develop a very basic "Hello World" style program. After you've built the compiler, please copy and paste the following code into a file with the FX extension. I chose CompiledHelloJavaFX.fx for my filename: /* This simple compiled JavaFX Script program is almost identical to what it would be if it were written in interpreted JavaFX Script. The difference (attribute initialization) is noted in the Converting to the New Syntax document that I've referred you to previously. To compile the program, set your PATH environment variable to the dist/bin directory of where you installed the JavaFX compiler. Then execute the proper javafxc command file for your operating system, passing your FX file as an argument. On my Windows machine, I navigate to the directory in which my FX file is located, and enter the following from the command prompt: javafxc CompiledHelloJavaFX.fx To run your program, set the CLASSPATH environment variable to the javafxc.jar file in the dist directory as well as the current directory, passing in the name of the JavaFX Script program without the FX extension. On my Windows machine, I enter the following from the command prompt: java -cp C:\openjfx-compiler\dist\javafxc.jar;. CompiledHelloJavaFX Note: If there is a package statement in your JavaFX Script program, then navigate to the directory in which the top node of the package is located. See Develop and Run Your First JavaFX Script Program in the Next Few Minutes for a discussion on the package statement. For a review, or to catch up if you're new to this Learn JavaFX blog, see the posts in the JavaFX Script category to learn the syntax of interpreted JavaFX Script programs. As I've noted before, JavaFX Script is migrating from being an interpreted language to becoming a compiled language. When compiled JavaFX Script is mature it will eventually replace interpreted JavaFX Script. Reader Feedback: Page 1 of 1
Subscribe to our RSS feeds now and receive the next article instantly!
Subscribe to the World's Most Powerful Newsletters
|
||||||||||||||