Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use Ruby classes packaged using warbler as a jar in Java code?

I've a ruby application which I compiled into a jar using warbler. I'm able to run it as a standalone using a command like java -jar executable.jar. But I'm unable to figure out how I'd use this jar in Java code. Specifically, I want to create objects of my Ruby classes in the Java code and then call the methods.

like image 955
arrac Avatar asked Jul 04 '13 06:07

arrac


1 Answers

You can start it with ProcessBuilder:

ProcessBuilder processBuilder = new ProcessBuilder("/path/to/java", "-jar", "executable.jar");
processBuilder.directory(new File("preferred/working/directory"));
Process process = processBuilder.start();

or another way if you use Windows:

Runtime.getRuntime().exec("cmd /c start executable.jar");
like image 75
MikroDel Avatar answered Oct 31 '22 22:10

MikroDel