Java.Java8.What is jjs?

✅ 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

StatusJava Version
DeprecatedJava 11
RemovedJava 15

Why? Because Nashorn couldn’t keep up with newer JavaScript standards (ES6+), and newer tools like GraalVM replaced it.


🧠 Summary

FeatureDescription
jjsJavaScript shell for Nashorn
UseRun JavaScript + call Java classes
Removed inJava 15
Replaced byGraalVM, Node.js for modern JS

This entry was posted in Без рубрики. Bookmark the permalink.

Leave a Reply

Your email address will not be published.