The Artima Developer Community
Sponsored Link

Java Buzz Forum
Undocumented JavaFX: The ScriptShell Repl

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Weiqi Gao

Posts: 1808
Nickname: weiqigao
Registered: Jun, 2003

Weiqi Gao is a Java programmer.
Undocumented JavaFX: The ScriptShell Repl Posted: Jun 19, 2009 6:10 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Weiqi Gao.
Original Post: Undocumented JavaFX: The ScriptShell Repl
Feed Title: Weiqi Gao's Weblog
Feed URL: http://www.weiqigao.com/blog/rss.xml
Feed Description: Sharing My Experience...
Latest Java Buzz Posts
Latest Java Buzz Posts by Weiqi Gao
Latest Posts From Weiqi Gao's Weblog

Advertisement

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.

Read: Undocumented JavaFX: The ScriptShell Repl

Topic: 5 Points to Remember for Facebook Personalized URL Previous Topic   Next Topic Topic: Virgin Media and Universal launch new music download subscription service

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use