Skip to content

Instantly share code, notes, and snippets.

@rjungemann
Forked from headius/gist:314044
Created February 25, 2010 00:51
Show Gist options
  • Save rjungemann/314088 to your computer and use it in GitHub Desktop.
Save rjungemann/314088 to your computer and use it in GitHub Desktop.
Little Java JS Rhino runner
~/projects/jruby ➔ cat remote_rhino.rb
require 'java'
$CLASSPATH << 'http://mirrors.ibiblio.org/pub/mirrors/maven2/rhino/js/1.7R2/js-1.7R2.jar'
ctx = org.mozilla.javascript.Context.enter
scope = ctx.init_standard_objects nil
result = ctx.evaluate_string scope, 'function f(x){return x+1} f(7)', 'x', 1, nil
puts result
~/projects/jruby ➔ jruby remote_rhino.rb
8.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment