Exciting times...since 2 weeks we have an updated version of JDK8 available for the Raspberry Pi and it's based on build b97 (well in the meantime we have b98 and b99 should be available soon). This means the restrictions that we had with the december build of JDK8 for the Pi are gone...e.g. custom controls that have been developed for the desktop will run on the Pi without modification...YAY!!! Finally I can test my standard Enzo build on the Pi which is awesome.
In addition to this we now also have 3D support and Nashorn on the Pi...and again YAY!!!
Now it's time to give the Nashorn some Pi and see if it works. I explained my idea some weeks ago, if you develop Java for the Raspberry Pi it's not that bad, you can develop your application on your desktop computer, create a jar, copy the jar to the Pi and start it there. That's ok...BUT if you would like to change something or test something this procedure could get boring because it's timeconsuming. So one possible solution might be using property files that you load at startup and so you have the chance to modify parameters. The disadvantage is that you have take care about each property in your app which means you have to know all the parameters you would like to change up front...not a really good solution.
When I read about Nashorn the idea came to my mind that it might be cool if I could access JavaFX controls from a script that could be loaded at runtime, so not only at startup but also when the application is running.
Well I tested that and it worked on the desktop so now it's time to test it on the Raspberry Pi.
In principle you could use the same code that I use for the "Taming the Nashorn again..." blog post to run a script at startup and you will figure out that it simply works.
You have to put the nashorn.jar which is in $JAVA_HOME/jre/lib/ext on the classpath (don't ask me why but Jim Laskey figured that out and it worked...thanx to Jim for the hint).
Because the polling of the Filesystem Listener is not that fast it could take a second or two before the Application will change but this is no problem because I can now modify a running application...sweet.
Well as you might know I'm a big fan of XMPP so why not using a simple chat to send the script directly to the JavaFX application on the Raspberry Pi and evaluate it by the Nashorn scripting engine. Long story short...it's just to easy to implement because you simply send a text message to the JavaFX application via XMPP and pass the script text to the Nashorn scripting engine where it will get interpreted...done :)
To give you an idea about how that works I've created a little screen video that I've put on YouTube.
To see the text in the shell window you should increase the screen size of the video.
I've put the code I used for the demo on a BitBucket repo, so feel free to take a look at it...
That's it for today...enjoy taming the Nashorn and keep coding...