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!
2 Correct answers
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
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
- 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
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!
Copy link to clipboard
Copied
@Dordrecht , Thanks to you too for your update and for sharing what you found.


-
- 1
- 2