| By James L. Weaver | Article Rating: |
|
| November 24, 2007 06:45 AM EST | Reads: |
11,903 |
From Jim Weaver's Learn JavaFX Weblog
The next JavaFX Puzzler will be posted at 18:00 GMT (1:00PM EST) on Wednesday, November 28, 2007. It will be a compiled JavaFX Script puzzler, so you'll need to build the JavaFX Script Compiler in order to participate in the Puzzler.
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:
/*
* CompiledHelloJavaFX.fx - A Hello World
* style compiled JavaFX Script program
*
* Developed 2007 by James L. Weaver
* (jim.weaver at lat-inc.com)
*/
import java.lang.System;
class CompiledHelloJavaFX {
attribute textToPrint:String =
"Hello Compiled JavaFX Script!";
}
var chjfx =
CompiledHelloJavaFX {
};
System.out.println(chjfx.textToPrint);
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.
Please post to the Feedback thread here any questions that you have as you build the JavaFX Script Compiler, and as you compile and run this example.
Published November 24, 2007 Reads 11,903
Copyright © 2007 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By James L. Weaver
James L. (Jim) Weaver is founder and president of jMentor, formed in 2000 to provide Java programming-related training to companies and individuals. He has served as a system architect and developer for over 25 years, specializing in leading-edge software development. His specialties include Java, object-oriented, and web-based technologies. He has authored books on the Java programming language, including most recently JavaFX Script, published by Apress.
![]() |
murthy 02/15/08 07:28:28 PM EST | |||
when i run m javafx program, there is an error! |
||||
- It's the Java vs. C++ Shootout Revisited!
- Patterns for Building High Performance Applications
- Asynchronous Logging Using Spring
- Java for Programmers (2nd Edition)
- Cross-Platform Mobile Website Development – a Tool Comparison
- Three Buzzwords That Every CIO Hears but One They Should Listen To
- Write Once Run Anywhere or Cross Platform Mobile Development Tools
- Immersing into JavaScript Frameworks
- Workday Reportedly Prepping to Go Public
- Cloud Expo New York: The Java EE 7 Platform - Developing for the Cloud
- Book Review: Sams Teach Yourself Java in 24 Hours
- OpenOffice.com Lives
- Book Excerpt: Introducing HTML5
- Adobe Sends Flex to the Apache Foundation
- Five Years Waiting for JRE 7: Is It Justified? (Part 1)
- Book Excerpt: Java Application Profiling Tips and Tricks
- i-Technology in 2012: Five Industry Predictions
- It's the Java vs. C++ Shootout Revisited!
- Patterns for Building High Performance Applications
- OpenXava 4.3: Rapid Java Web Development
- The Next Web Architecture
- Asynchronous Logging Using Spring
- Java for Programmers (2nd Edition)
- Is Write Once Run Anywhere Ever Going to Be a Reality?
- A Cup of AJAX? Nay, Just Regular Java Please
- Java Developer's Journal Exclusive: 2006 "JDJ Editors' Choice" Awards
- JavaServer Faces (JSF) vs Struts
- The i-Technology Right Stuff
- Rich Internet Applications with Adobe Flex 2 and Java
- Java vs C++ "Shootout" Revisited
- Bean-Managed Persistence Using a Proxy List
- Reporting Made Easy with JasperReports and Hibernate
- Creating a Pet Store Application with JavaServer Faces, Spring, and Hibernate
- Why Do 'Cool Kids' Choose Ruby or PHP to Build Websites Instead of Java?
- What's New in Eclipse?
- i-Technology Predictions for 2007: Where's It All Headed?



















