GraalJS
A high-performance embeddable JavaScript runtime for Java
Benefits
JavaScript for Java
Use JavaScript modules and scripts directly in Java
ECMAScript Compliant
Fully implements the ECMAScript 2024 Language Specification
Fastest JavaScript on the JVM
Graal JIT compiles JavaScript for native code speed
Modern JavaScript for the JVM
An upgrade path for Nashorn and Rhino applications to ECMAScript 2024
Script Java with JavaScript
Extend applications with JavaScript that interacts with Java classes and framework
WebAssembly Integration
Use WebAssembly modules through the JavaScript WebAssembly API
How to Get Started
1. Add GraalJS as a dependency from Maven Central
<dependency>
<groupId>org.graalvm.polyglot</groupId>
<artifactId>polyglot</artifactId>
<version>24.1.1</version>
</dependency>
<dependency>
<groupId>org.graalvm.polyglot</groupId>
<artifactId>js</artifactId>
<version>24.1.1</version>
<type>pom</type>
</dependency>
or
implementation("org.graalvm.polyglot:polyglot:24.1.1")
implementation("org.graalvm.polyglot:js:24.1.1")
2. Embed JavaScript code in Java
import org.graalvm.polyglot.Context;
try (Context context = Context.create()) {
context.eval("js", "console.log('Hello from GraalJS!')");
}
GraalJS Quick Start
Jump right in with this starter project
Use Cases
Micronaut’s React SSR: boosting performance with GraalJS
Micronaut’s React SSR runs Javascript with high performance using GraalJS
GraalJS-powered execution engine for the HTTP Client in IntelliJ
IntelliJ IDEA upgraded the JavaScript execution engine used in the HTTP Client to GraalJS
High-performance server-side rendering on the JVM
High-performance server-side rendering for React.js and other client frameworks
NetSuite leverages GraalJS for its SuiteScript extension language
NetSuite chose GraalJS as their JavaScript runtime because of its support for the latest ECMAScript standards and enhanced performance
There are significant benefits with the GraalJS runtime environment and how that gives SuiteScript developers access to the most current ECMAScript features and syntax out of the box. Aligning SuiteScript with ECMAScript delivers enhanced developer productivity, more maintainable code and ensures ongoing conformance to an evolving standard.