The recently released JavaFX SDK 1.2 includes the developer tools javafxc, javafx, and javafxdoc that are similar to the javac, java, and javadoc tools from the JDK.
What is not well-known is the fact that the JavaFX SDK 1.2 also includes a read-eval-print loop (repl) that developers can use for exploratory programming.
Well, almost. The Java class for the repl is included in the javafxc.jar file that is part of the SDK. However no command line tool for invoking the repl is available.
It is not hard to modify the existing javafx shell script to create a launcher script for the repl. That's what I did yesterday evening. I also throw in some JLine magic so that command line editing works. Here is javafxsh, shell script for the JavaFX Script repl. And for Windows users, here is javafxsh.exe (Cygwin users running rxvt or xterm should use the shell script). Just throw these into your javafx-sdk1.2/bin directory, and add the jline-0.9.94.jar file into your CLASSPATH environment variable, you are in business.
To comply with the GPL v.2 license of the original OpenJFX-Compiler, I've put my modified version of the source here. All of my modifications are also GPL v.2 licensed, so that you can further enhance it if you wish.
The repl is actually fully documented here by its author Per Bothner. The claim in the title of the post about undocumented-ness refers to the fact that the JavaFX SDK itself does not contain any documentation of this feature.
Here is an interactive session of me playing with javafxsh:
[weiqi@gao] $ javafxsh
/*fx1*/ function fib(n:Integer):Integer{ if (n<=1) n else fib(n-1) + fib(n-2) }
/*fx2*/ fib(6)
8
/*fx3*/
The current version of the repl has some limitations, e.g., it doesn't handle multi-line expressions yet. It also allows you some latitude in redefining variables, which is illegal under the compiler. However, there are considerable amount of experiments that can be done in the repl.
I hope you enjoy playing with JavaFX Script in a repl. And let me know if you encounter any problems.