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.
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");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With