Advertisement
Guest User

Untitled

a guest
Feb 25th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1.     private ScriptingContainer ruby;
  2.  
  3.     @Test
  4.     //@Ignore
  5.     public void testJRuby() {
  6.         ruby = new ScriptingContainer(LocalVariableBehavior.PERSISTENT);
  7.             // Assign the Java objects that you want to share
  8.         ruby.put("main", this);
  9.             // Execute a script (can be of any length, and taken from a file)
  10.         Object result = ruby.runScriptlet("main.hello_world");
  11.             // Use the result as if it were a Java object
  12.         System.out.println(result);
  13.     }
  14.  
  15.     public String getHelloWorld() {
  16.         return "Hello, worlds!";
  17.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement