All Questions

24
votes
2answers
61815 views

Call external javascript functions from java code

By using Java Scripting API, I am able to execute JavaScript within Java. However, can someone please explain what I would need to add to this code in order to be able to call on functions that are in...
7
votes
3answers
4703 views

Has anyone used or written an Ant task to compile (Rhino) JavaScript to Java bytecode?

I'd like to use the Rhino JavaScript compiler to compile some JavaScript to .class bytecode files for use in a project. It seems like this should already exist, since there are groovyc, netrexxc, and ...
35
votes
6answers
11786 views

How can you run Javascript using Rhino for Java in a sandbox?

Part of our java application needs to run javascript that is written by non-developers. These non-developers are using javascript for data formatting. (Simple logic and string concatenation mostly). ...
10
votes
6answers
10377 views

ANT script to compile all (css) LESS files in a dir and subdirs with RHINO

I want do compile all *.less scripts in a specific folder and it subdirs with less-rhino-1.1.3.js. There is an example on github for doing this for a specific file, which works perfect. But I want t...
17
votes
4answers
20769 views

How to convert Rhino-JavaScript arrays to Java-Arrays

I have the following: ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine jsEngine = mgr.getEngineByName("JavaScript"); jsEngine.eval("function getArray() {return [1,2,3,4,5];};"); Obje...
12
votes
1answers
16857 views

Rhino: How to call JS function from Java

I'm using Mozilla Rhino 1.7r2 (not the JDK version), and I want to call a JS function from Java. My JS function is like this: function abc(x,y) { return x+y } How do I do this? Edit: (The JS fu...
17
votes
3answers
8137 views

Problems using Rhino on Android

I'm trying to use Mozilla Rhino in my Java application for Android to evaluate some JavaScript. I am using Eclipse + ADT plugin. First I tried simply downloading the Rhino .jar file from Mozilla's we...
12
votes
3answers
7095 views

How can I add methods from a Java class as global functions in Javascript using Rhino?

I have a simple Java class that has some methods: public class Utils { public void deal(String price, int amount) { // .... } public void bid(String price, int amount) { /...
5
votes
6answers
3845 views

testing an internal class

how to write unit tests to internal classes ???
12
votes
1answers
24752 views

ReferenceError: "alert" is not defined

I am trying to call a java script function from java code. Here is my Java code public static void main(String[] args) throws FileNotFoundException { try { /** * To call a a...

Previous Next