Reputation: 18149
I am trying to use Nashorn as a scripting language and I would like to start a Java program from that a script that is run with Nashorn.
I can sucsessfully run the following script with Nashorn:
#!/usr/bin/jjs -fv
$EXEC("ls -l")
However the following script seems to do nothing:
#!/usr/bin/jjs -fv
$EXEC("java -version")
On the commandline java -version
of course works...
What might be my problem?
Upvotes: 1
Views: 200
Reputation: 69663
Nashorn can call methods from Java classes. So you can just use it to evoke the main
-method of the main class of the program you want to start. A precondition is that you run jjs with the the parameter -cp path/to/java/classes/of/program
so it knows about the classes of said program.
Upvotes: 1