Questions tagged [jjs]

A command-line tool that accepts a list of JavaScript source code files as arguments for working with Oracle Nashorn

15 questions
5
votes
1 answer

How do I get jjs --add-opens to work in java9?

I have been using a reflection technique from https://apimeister.com/2015/06/27/add-jar-to-the-classpath-at-runtime-in-jjs.html to load classes at runtime in java's nashorn jjs. It works in java 8, but in java 9 it doesn't. I know about the…
J. Brazile
  • 781
  • 4
  • 9
2
votes
0 answers

Java 1.8 161+ jjs, cannot run using windows classpath

Trying to run jjs on windows using jdk1.8.0_171: D:\Java\64\jre1.8.0_171\bin\jjs.exe -cp…
Gary McWilliams
  • 335
  • 3
  • 4
  • 9
2
votes
0 answers

Classpath resources with Nashorn (JJS)

I've noticed that, when using nashorn's command line utility JJS, any resource that is included in the classpath, be it included in a JAR or located in a classpath folder, is not available to scripts. A simple example: echo…
emerino
  • 1,100
  • 11
  • 17
2
votes
1 answer

JMX connection via Nashorn javascript jjs

I am writing a script in JavaScript engine that comes with JDK8. This script will use JMX to connect to a remote Java instance. I am using authentication, but no SSL. The JMX connection is working fine from any JMX client, the problem is in this…
Mircea Vutcovici
  • 1,894
  • 19
  • 27
1
vote
2 answers

Getting "speechSynthesis" is not defined in jjs(Java JavaScript)

I am attempting to access the SpeechSynthesis interface for speech service with the help of the Nashorn engine in java. Is it possible to import or create a similar SpeechSynthesis interface to the Nashorn engine Or any other javascript engine with…
1
vote
1 answer

How can I pass multiple Nashorn arguments when I launch a jar?

I am trying to pass multiple Nashorn arguments when I start a jar, something like this: java -Dnashorn.args=-scripting -t -jar myjar.jar The second Nashorn argument -t doesn't seem to be processed, and I get this: Unrecognized option: -Xt Error:…
Youness
  • 57
  • 8
1
vote
2 answers

How to exit Nashorn jjs command line tool?

If I start up the Nashorn CLI via jjs, I can't cleanly exit it without using ctrlc. I tried: exit quit System.exit() But none worked.
Bohemian
  • 412,405
  • 93
  • 575
  • 722
0
votes
1 answer

Want to run JavaScript code snippet which returns Boolean with the help of java

I want to run a JavaScript code snippet which returns boolean, from java. Currently I am using ProcessBuilder to run the JavaScript program with the command jjs filename. I am able to perform the operations and getting the output from…
0
votes
1 answer

change this javascript to generate more than one random number

running this code will give me one random number what I need is to change it to generate me 1000 on each run function randomdnumber(){ var randomdnumber = ""; var nb = new Array(); nb[9] = 0; for(i = 0,y = 10 ; i < 9 ; i++,y--) …
RaVao3
  • 11
0
votes
3 answers

Get collection of elements from JSON

I have a JSON file with the structure as below: {"root" : { "parent" : { "childA" : ["element1", "element2"], "childB" : ["element1", "element2"] } } How can I…
blekione
  • 10,152
  • 3
  • 20
  • 26
0
votes
1 answer

Nashorn JJS: incuding all jars in folder at cpasspath

I am using Nashorn's JJS with -classpath to load all the jars in a folder. I have tried the following : jjs -J-Xmx512m -J-XX:MaxDirectMemorySize=512m -cp "C:/orientDB/lib/*" test.js "Illegal char <> at index 16: C:/orientDB/lib/" is not a…
adamM
  • 1,116
  • 10
  • 29
0
votes
1 answer

Nashorn JJS: set heap size on command line

Using the JJS tool for Nashorn+ JVM, how do we set JVM arguments? I tried this: jjs -Xmx512m test.js but got this: "-Xmx512m" is not a recognized option. Use "-h" or "-help" to see a list of all supported options. Sepcifically I want to set…
adamM
  • 1,116
  • 10
  • 29
0
votes
1 answer

Nashorn/jjs security: executing a user's script on server side

I'm writing an application where the user can provide a custom javascript function to filter a file on the server side using nashorn/jjs: cat /etc/js/library.js user.js > tmp.js && cat /path/to/input.txt | jjs --language=es6 -doe…
Pierre
  • 34,472
  • 31
  • 113
  • 192
0
votes
2 answers

Writing a `jjs` shebanged script that accepts just arguments

Supposedly jjs is the Java 8 version of nashorn, ready for shell-scripting. However when I write a file with execute permission as: #!/usr/bin/jjs arguments.forEach(function(v,i,a){print(v);}); Running it produces some not so ideal shell-scripting…
dlamblin
  • 43,965
  • 20
  • 101
  • 140
-1
votes
1 answer

What objects are available in jjs?

When I am running Javascript in a browser I have the document object available to me. For instance, I can do document.write() in javascript in a browser. The document object is not available when I am running Javascript under the Java 8 Javascript…
Be Kind To New Users
  • 9,672
  • 13
  • 78
  • 125