I was able to get all three running a Hello World in a "Scala Project" with a .java
file as my main. The problem is that it is pulling from a "Java Project" I am not using, though I have the JRE System Library in my "Scala Project". Here is the code as to what I am doing to help understand...
JRuby.java
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!");
}
}
ScallaHello.scala
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!")
}
End results are...
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!
I have the jars organized as the Scala Library, JRE Library and Referenced Libraries for the JRuby Jar. I also have the same in the "Java Project" that I don't want to use. If I close that project, this project, "Scala Project" fails to run. Obviously this is not an important project, but I am wanting to better understand how this works.