YOUR FEEDBACK
More on the Software Assembly Question - Do Design Patterns Help?
Yanic wrote: Hi, > UML and MDA are being changed to be more data and doc...


2007 West
GOLD SPONSORS:
Active Endpoints
Your SOA Needs BPEL for Orchestration
BEA
Virtualized SOA: Adaptive Infrastructure for Demanding Applications
Nexaweb
Overcoming Bandwidth Challenges with Nexaweb
TIBCO
What is Service Virtualization?
SILVER SPONSORS:
WSO2
Using Web Services Technologies and FOSS Solutions
Click For 2007 East
Event Webcasts

2008 East
PLATINUM SPONSORS:
Appcelerator
Think Fast: Accelerate AJAX Development with Appcelerator
GOLD SPONSORS:
DreamFace Interactive
The Ultimate Framework for Creating Personalized Web 2.0 Mashups
ICEsoft
AJAX and Social Computing for the Enterprise
Kaazing
Enterprise Comet: Real–Time, Real–Time, or Real–Time Web 2.0?
Nexaweb
Now Playing: Desktop Apps in the Browser!
Sun
jMaki as an AJAX Mashup Framework
POWER PANELS:
The Business Value
of RIAs
What Lies Beyond AJAX?
KEYNOTES:
Douglas Crockford
Can We Fix the Web?
Anthony Franco
2008: The Year of the RIA
Click For 2007 Event Webcasts
SYS-CON.TV
TOP THREE LINKS YOU MUST CLICK ON


Developing Your First Compiled JavaFX Script Program
CompiledHelloJavaFX

Digg This!

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.

About 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 wrote: when i run m javafx program, there is an error! the Frame class is not found... please help me
read & respond »
LATEST JAVA STORIES & POSTS
JavaOne 2008: A Developer's Perspective
This is my third JavaOne. Many topics were discussed, friendships were made, new partnerships were started. I must say things have changed a lot and stayed the same yet again, here are my thoughts in no particular order, bear in mind that they do not represent the opinion of my c
3rd International Virtualization Conference & Expo: Themes & Topics
From Application Virtualization to Xen, a round-up of the virtualization themes & topics being discussed in NYC June 23-24, 2008 by the world-class speaker faculty at the 3rd International Virtualization Conference & Expo being held by SYS-CON Events in The Roosevelt Hotel, in mi
A Lightweight Approach to SOA and BPM in Java Using jBPM
SOA is mostly associated with technologies such as BPEL, SCA and Web Services. But does SOA really imply these technologies? In this session we will show how you can use the service oriented approach while staying inside the Java world. jBPM is a powerful lightweight framework th
Case Study: Java and the Mac
This is the story of a Mac application developer (okay - it's about two of them) who set out on a quest to find an application development tool based on Java so his boss would let him develop on the Mac platform, which he loved. There was only one catch - he had to find a tool th
eApps Hosting Now Offers the GlassFish Java Application Server in VPS Hosting Plans
eApps Hosting announced that the GlassFish Open Source Application Server for Java EE 5, from the GlassFish community project, is now available as a click installable application service in low cost Virtual Private Server (VPS) hosting plans. The eApps Hosting service has support
The 4 Core Principles of Agile Programming
One of the things I really enjoy at the moment is the recognition and adoption of agile programming as a fully fledged powerful way to deliver quality software projects. As its figurehead is a group of very talented individuals who have created the agile manifesto (http://agilema
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE
BREAKING JAVA NEWS
Five Sun Microsystems Women Honored with Prestigious Awards
Sun Microsystems, Inc. (NASDAQ:JAVA) today announced that five Sun women have been awar