
See the code first, then we will get into the tutorial on how to set up your environment. I will clean up the style of this tutorial later, I just wanted to get it up.
import org.jruby.embed.ScriptingContainer;
public class JRuby {
public static void main(String[] args)
{
System.out.println("Java, Scala and Ruby using the JRE.\n");
ScriptingContainer container = new ScriptingContainer();
container.runScriptlet("puts 'This is JRuby code in .java file!'");
new ScallaHello().hello();
System.out.println("This is standard Java Code in .java file!");
}
}
class ScallaHello {
def hello() {
println("This is a Scala Method in .scala file, object set in .java file")
}
System.out.println("This is Java Code in .scala file!")
println("This is Scalla Code in .scala file!")
}
Java, Scala and Ruby using the JRE.
This is JRuby code in .java file!
This is Java Code in .scala file!
This is Scalla Code in .scala file!
This is a Scala Method in .scala file, object set in .java file
This is standard Java Code in .java file!
If you already have Eclipse, you should be able to use that version, or follow these steps and install another Eclipse to keep this environment separate.
Follow instructions. At the time of this install, it involves pasting the download page/link into your Eclipse “Install New Software” section under the Help Tab in Eclipse.
Make sure you expand these and see all boxes, select ‘Select All’ then select Next>, select Next> again to install. Accept terms and select Finish. Make sure you go through terms that need to select and see all windows for this are selected. I ran into an issue downloading until I went through the checkboxes and “Accept Terms” more thoroughly. Once everything installs properly it should restart or ask for a restart.
Now Eclipse and Scala should be installed, but it still needs to be configured to work properly.


Now we are going to take a break from Scala and download JRuby. This step can be skipped if you don’t want Ruby, or you can use this a the only step to just add JRuby to a Java project.
Download JRuby

Back to configuring your project in Eclipse…


That should cover everything for your Hello World of Java, Scala and Ruby. If you have any issues, please ask and I will be happy to help.