✅ What is jjs
?
jjs
was a command-line tool introduced in Java 8 that allowed you to run JavaScript code directly using the Nashorn JavaScript engine.
Think of it as a mini JavaScript REPL or script runner inside your JDK.
🔹 Example Usage
jjs
You’d get an interactive shell like this:
jjs> print("Hello from Nashorn!");
Hello from Nashorn!
Or run a script file:
jjs myscript.js
✅ What Could You Do with jjs
?
- Run JavaScript code from the terminal
- Import and use Java classes from JavaScript
- Do quick scripting or automation tasks using the JVM
🔧 Example: Calling Java from JavaScript
// hello.js
var ArrayList = Java.type("java.util.ArrayList");
var list = new ArrayList();
list.add("Java + JS");
print(list.get(0));
Then run:
jjs hello.js
❌ Deprecation & Removal
Status | Java Version |
---|---|
Deprecated | Java 11 |
Removed | Java 15 |
Why? Because Nashorn couldn’t keep up with newer JavaScript standards (ES6+), and newer tools like GraalVM replaced it.
🧠 Summary
Feature | Description |
---|---|
jjs | JavaScript shell for Nashorn |
Use | Run JavaScript + call Java classes |
Removed in | Java 15 |
Replaced by | GraalVM, Node.js for modern JS |