Oracle Blog

Ryan Kopf at the U of I

Calling JRuby in Java

We all know that JRuby can easily use Java classes, but did you know Java can call JRuby scripts? An excellent but relatively underutilized feature of Java and JRuby is the ability to call JRuby scripts directly from your Java program. Consider the possibilities of loading a JRuby script, from possible a text file or a database, and having it execute within your program. It could be an excellent method of installing on-the-fly system updates or modifying variables that you never thought you'd need to touch. Always, of course, be careful not to execute malicious code, as your JRuby script can do anything your Java code might.