Skip to Main Content

SQL Developer

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Recommended way to use SQLcl JavaScript scripting with JDK 21?

rode_mb6 days ago

Hi SQLcl team,

I am currently using a recent SQLcl version with JDK 21. Since Nashorn is no longer part of modern JDKs, the SQLcl JavaScript scripting feature is not available out of the box when running on a standard JDK 21.

I found the documented recommendation that JavaScript support requires GraalVM for Java 17 with the JavaScript Runtime plugin. However, I would prefer to keep using a standard JDK 21 runtime for SQLcl if possible.

I tested the following approach:

  1. Use standard JDK 21, not GraalVM.
  2. Resolve GraalJS dependencies from Maven Central.
  3. Add the resulting classpath to SQLcl’s CPLIST.

For example, I use a small Maven project like this:

<project xmlns="http://maven.apache.org/POM/4.0.0" 
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
                             http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>graaljs</groupId>
  <artifactId>graaljs</artifactId>
  <version>1.0</version>

  <dependencies>
    <dependency>
      <groupId>org.graalvm.js</groupId>
      <artifactId>js-scriptengine</artifactId>
      <version>25.0.3</version>
    </dependency>

    <dependency>
      <groupId>org.graalvm.polyglot</groupId>
      <artifactId>js</artifactId>
      <version>25.0.3</version>
      <type>pom</type>
    </dependency>
  </dependencies>
</project>

Then I create the runtime classpath, for example with:

mvn dependency:build-classpath -Dmdep.outputFile=graaljs.classpath

and add that classpath to CPLIST before starting SQLcl.

With this setup, SQLcl is still running on JDK 21, but the JavaScript ScriptEngine is provided by GraalJS via the additional classpath.

My question is:

Is this considered a valid and supported way to enable SQLcl JavaScript scripting on JDK 21?

Or is the only recommended/supported configuration still to run SQLcl with GraalVM for Java 17 plus the JavaScript Runtime plugin?

I am mainly trying to understand whether the Maven-based GraalJS classpath approach is safe to use for regular SQLcl scripting, or whether it should be treated as an unsupported workaround.

Thanks!

Comments
Post Details
Added 6 days ago
1 comment
45 views