Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Nashorn Scripting Engine Replacement/Implementation?

Participant ,
Feb 04, 2025 Feb 04, 2025

Copy link to clipboard

Copied

Hi all.

 

ColdFusion 2021 uses Java 11 and ColdFusion 2023 uses Java 17. Java 11 contained the Nashorn Scripting Engine, which is used in my CF 2021 code to run JavaScript on the back end, but Nashorn was removed from Java 17, so I'm looking for the best way to replace what it did in ColdFusion 2023. Has anyone else successfully done this?

 

Apparently Nashorn is now available as a standalone package but I'm not a Java guy, so I don't know how to get it into a form that ColdFusion can use (maybe a jar file). Would anyone else know how to go about this?

 

Another alternative is the GraalJS scripting engine, which I understand can duplicate what Nashorn did, but again, how can this be put into a ColdFusion-usable library or installation?

 

Any help would be greatly appreciated!

Views

681
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Feb 09, 2025 Feb 09, 2025

Hi @Dordrecht ,

I have found a way to solve the problem on Java 17.  It involves using the OpenJDK Nashorn version, as suggested in this Stackoverflow post: https://stackoverflow.com/questions/68108169/does-nashorn-org-openjdk-nashorn-have-any-support-for-java-17 .  The version I have successfully tested is Nashorn-core 15.6.

 

You can see from the Nashorn-core 15.6 documentation that its dependencies are

  • asm
  • asm-commons
  • asm-tree
  • asm-util


Each dependency corresponds to a Jar file. So, to imple

...

Votes

Translate
Community Expert , Feb 24, 2025 Feb 24, 2025

It has been a long search. But I can now provide an update. I have been able to create a proof-of-concept of GraalJS in ColdFusion.

 

The proof-of-concept consists of CFML code that uses GraalJS to evaluate Javascript source code, and produce a result.

 

Proof-of-Concept

The steps I followed in creating the proof-of-concept

 

  1. Create a Maven project
    I created a project in Maven. However, I didn't need to install Maven, as ColdFusion 2023 comes with Maven already installed. It is located at C:\Col
...

Votes

Translate
Participant ,
Mar 03, 2025 Mar 03, 2025

Copy link to clipboard

Copied

@BKBK , I have started to go thorugh your solution. In step 4, immediately after running mvn dependency:copy-dependencies, I get the error "The JAVA_HOME environment variable is not defined correctly, this environment variable is needeed to run this program." I defined a new JAVA_HOME environment variable with value of C:\ColdFusion2023\jre and added %JAVA_HOME%\bin to the path. After doing this and then closing and reopening the command window, I was able to generate the necessary files. 

 

Subsequently I was able to follow the other instructions and get the square root example to work. I'm planning on working more on this in the coming days, and I'll report on how it is going. Thanks again!

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 04, 2025 Mar 04, 2025

Copy link to clipboard

Copied

@Dordrecht , Thanks to you too for your update and for sharing what you found. 

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources