Beste,
Greetings from JavaPolis 2007 the JavaOne of Europe. It is held in in Antwerp, Belgium, at an amazing facility known as the Metropolis. Each of the presentation rooms is a large, comfortable, movie theater! After a long transatlantic flight, I arrived here yesterday morning to give two presentations on JavaFX Script. These presentations will occur Tuesday and Wednesday, so today I was able to listen to two excellent three-hour "university" sessions.
- Introduction to AJAX, presented by Sang Shin. Check out his Java with Passion! site.
- Introduction to JRuby, presented by Brian Leonard. Check out his Java technologies weblog. Brian "got by with a little help from his friends", as Charles Nutter (one of the JRuby Core Engineers) gave a great technical review of the current state of JRuby. Check out his Headius weblog, whose stated purpose is "Helping Ruby and Java Evolve Together".
In some free time today I put the finishing touches on my presentations, and in the process developed the following example JavaFX Script program. It has a JavaPolis 2007 theme (see Star Wars meets JavaPolis), and was created to demonstrate how to instantiate and use Java classes from JavaFX Script. See earlier posts for how to compile and run a compiled JavaFX Script program. Here's the program:
/*
* CreateJavaObject.fx - Example of creating Java object
*
* Developed 2007 by James L. Weaver (jim.weaver at lat-inc dot com)
*/
import java.lang.System;
import java.util.HashMap;
var jahVa = new HashMap();
jahVa.put("enjoys", "hashcode");
jahVa.put("dislikes", "dot-not");
System.out.println("Jah-va dislikes {jahVa.get("dislikes")}");
var jahVaEnjoys = jahVa.get("enjoys");
System.out.println("Jah-va enjoys {jahVaEnjoys}");
This example highlights one of the big advantages of JavaFX Script -- the ability to leverage the power of the Java classes that exist today, as well as ones that you or others may write in the future.
By the way, here's a heads-up if you happen to be at JavaPolis this week: I'm going to be giving away some eBook copies of my JavaFX Script book to some audience members during both of my presentations. They will be awarded based upon audience member participation (e.g. asking and answering questions).
Met vriendelijke groet,
Jim Weaver
JavaFX Script: Dynamic Java Scripting for Rich Internet/Client-side Applications
eBook (PDF) download available at the book's Apress site
There is no exact definition of the word happiness. Happy people are happy for all sorts of reasons. The key is not wealth or physical well-being, since we find beggars, invalids and so-called failures, who are extremely happy.
Posted by: coach purses | June 24, 2010 at 03:32 AM
Hi, Jim
Actually I was able to fix the problem a few moments after my yesterday's post. What I did was precisely what you've posted, just added the argument -classpath in the compile command line and it worked perfectly. But thanks for the post, anyway.
Having this basic problem solved, i'm now trying to take JavaFX up a notch and create a daytime client applet that simply asks a remote server for the time. I works perfecly under an IDE but things get a bit messy when I run it in a browser. Security issues I guess...:S
Thanks a lot, Jim.
Posted by: Joao (John in Portuguese :P) | March 04, 2008 at 11:50 AM
Joao (John),
I don't see any obvious mistakes. Is the Java class on the classpath?
Thanks,
Jim Weaver
Posted by: Jim Weaver | March 03, 2008 at 09:27 PM
Hey,
This is example on Java Classes with Compiled JavaFX is all pretty OK! But I'm running in a bit of a problem when I try to use this concept with my own java classes.
I import into my fx file the java class (held upon another package). Kind like this:
package my.company.whatever.fx_files;
...
import my.company.whatever.java_files.MyClass;
...
...
var m = new MyClass();
...
...
but when I try to compile my fx file it just doesn't seem to see that package. It displays an error that there is no such package.
What would you say that is wrong with this approach?
Posted by: Joao (John in Portuguese :P) | March 03, 2008 at 06:24 AM