http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
http://joelinoff.com/blog/?p=783
https://github.com/jrburke/r.js/
instructions on the github page
http://tschaub.net/blog/2011/05/17/commonjs-modules-with-rhino.html
really straightforward tutorial
https://github.com/mozilla/rhino/tree/master/examples
OS X, linux, bsd, etc
mvn archetype:generate -DgroupId=com.abe.app -DartifactId=abe-app -DarchetypeArtifactId=abe-quickstart -DinteractiveMode=false
cd abe-app
in the … section
<dependency>
<groupId>org.mozilla</groupId>
<artifactId>rhino</artifactId>
<version>1.7R4</version>
</dependency>
By adding this dependency when compiling with maven, it will automatically be included in the compile call. The replaces the need to manipulate classpath and call javac manually.
http://mvnrepository.com/artifact/org.mozilla/rhino/1.7R4
notice that the Maven tab has the block filled out for you
import org.mozilla.javascript.*;
// Creates and enters a Context. The Context stores information
// about the execution environment of a script.
Context cx = Context.enter();
try {
// Initialize the standard objects (Object, Function, etc.)
// This must be done before scripts can be executed. Returns
// a scope object that we use in later calls.
Scriptable scope = cx.initStandardObjects();
String s = "Math.cos(Math.PI);";
// Now evaluate the string we've colected.
Object result = cx.evaluateString(scope, s, "<cmd>", 1, null);
// Convert the result to a string and print it.
System.err.println(Context.toString(result));
} finally {
// Exit from the context.
Context.exit();
}
mvn package
you must include the classpath manually in your java call, or modify the $CLASSPATH shell var
java -cp ~/.m2/repository/org/mozilla/rhino/1.7R4/rhino-1.7R4.jar:target/abe-app-1.0-SNAPSHOT.jar com.abe.app.App
note that ~/.m2 is the default location for Maven local class installations.