This is probably the #1 power feature for SQLcl, the ability to run JavaScript. The examples I use to demonstrate this the most are:
- creating custom sql outputs – a Card Format
- loading files from a directory to BLOBs in a table
- exporting BLOBs from a table to a directory
For example in just a few lines of code…

No support for Nashorn in Java 17
What is Nashorn? It basically allowed for the JVM to also support running JavaScript. It’s much more than that, but end of day, it’s close.
The feature was deprecated in Java 11. It was completely removed in Java 15.
SQLcl ONLY support Oracle Java 11 and 17 today, so you need to run 11 if you want to use the script command to work with js.

What happens if you try with Java 17?

How to fix it
You have two options, Oracle Java 11 or the GraalVM for Java 11.
Now, why would we look at GraalVM?

Faster always sounds good to me, let’s give that a try!
I’m going to get Oracle GraalVM Enterprise Edition 22.0.0.2 Windows x86 for Java 11, Download GraalVM
I simply unzip that.
Then open a cmd prompt.
Set JAVA_HOME.

Start SQLcl.

Then let’s run our script command, again.

Using JAVA_HOME to tell SQLcl where to find Java
That’s brand new in SQLcl 22.1. On Windows, the native EXE was coded to go straight to the Windows Registry to look for Java. It made switching between versions of Java on Windows painful.
Now, if you use a Windows Installer to put down Java 11, it should setup your Windows machine to use it by default, and SQLcl will be impacted by that.
But now in 22.1, you can simply set JAVA_HOME to the Java Home you want the sql.exe to use, and you’re good. Turloch, if you’re reading this, we all say, ‘Thank you!’
7 Comments
Hello,
Do you thing it might be possible that sqlcl would come compiled with GraalVM?
Regards,
Jean
YES – and VERY VERY SOON 🙂
@leor, Good news. GraalVM now supports version 17.
While SQL Developer does not officially support Java 17, it still works there too. Me like!
OK but people are going to migrate to JDK 17. then what?
11 is supported until 2026, I’ll have an answer for you before then.
Hi Jeff,
GraalVM sounds great, but… what about the licensing? Does this mean that GraalVM would now fall into the scope of MOS Doc 1557737.1 (Support Entitlement for Java SE When Used As Part of Another Oracle Product)? The following FAQs (https://www.oracle.com/a/ocom/docs/jss-graalvme-customer-faq-20210107.pdf), back from January 2021, suggests it wasn’t always so.
Thanks & Regards,
Yes.