Java 8 was just a great release! We already talked about Lambdas and created JavaFX 8 apps on this blog. Bruno Borges created a fx2048 , a JavaFX version of the famous 2048 game, which shows Lambdas and the Stream library usage. Today I'll rewrite the Sentiments App view in Javascript using the new JS engine named Nashorn , one of the exciting Java 8 new features. Loading the Script We load a file with the view contents, but before doing this, we add the main Stage so it can be referenced from the javascript file. That's enough for the Java part! package org.jugvale.sentiments.view; import javafx.application.Application; import javafx.stage.Stage; import javax.script.*; import java.io.FileReader; public class AppJS extends Application{ private final String SCRIPT = getClass().getResource("/sentimentsView.js").getPath(); public static void main(String args[]){ launch(args); } @Override public voi...
Blog about programming and client applications. Target Programming languages are JavaFX, Visage, HTML 5+ Javascript or even command line apps :-D