---
title: "Preview of Charting in SQLcl via Oracle JET, Nashorn and JavaFX"
slug: "preview-of-charting-in-sqlcl-via-oracle-jet"
date: 2017-09-13T22:57:36Z
author: "Justin Biard"
tags:
  - "oracle sqlcl"
  - "nashorn"
  - "oracle jet"
description: "This is an example of connecting SQLcl and Oracle JET using the Nashorn scripting engine. Oracle JET application templates are deployed behind the scenes and data is loaded interactively from SQLcl sessions."
draft: false
archive: true
---

I will share a detailed writeup for this but in the meantime I wanted to share an example of the capabilities that Nashorn brings to the table with SQLcl as a front end. This is a work in progress SQLcl command I'm building as a proof of concept.

![sqlcl_oj-charts_001](https://icodealot.com/img/7339b1b1/sqlcl_oj-charts_001.gif)

Thanks to Jim Laskey for [blogging the sample code](https://blogs.oracle.com/nashorn/porting-from-the-browser-to-nashornjavafx-part-i) that got me started.

```javascript
var Scene = Java.type("javafx.scene.Scene");
var WebView = Java.type("javafx.scene.web.WebView");

var url = "https://icodealot.com";
var web = new WebView();
web.engine.load(url);

$STAGE.title = url;
$STAGE.scene = new Scene(web, 800, 600);
$STAGE.show();

```

This sample code is setup to run from the `jjs` command-line utility that comes with Java 1.8+. This is an interactive Nashorn scripting environment that you can use to run JavaScript code such as the above snippet.

The above JavaScript code is directionally correct but no spoilers here. There are many differences between scripting this in SQLcl vs. using `jjs`. You would run it on `jjs` with a command such as:

```batch
jjs -fx -scripting example.js

```

- -fx tells `jjs` to load the script as a JavaFX application
- -scripting tells `jjs` to enable shell scripting features

You can read more about `jjs` [here](https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jjs.html).

The solution I'm working on uses Oracle SQLcl, Nashorn (for scripting), Oracle JET for the HTML templates and charts. I am still working on the code to pull data from SQL queries against the Oracle database and Oracle REST Data Services (ORDS).

More to come!
