Hi, I have a list of binaries written in java, ada,C, python and I want to execute them. How to do that ? Is there any JVM binding to those languages ? Thanks for your answers
+1
A:
If all you want to do is execute existing applictions, you can use the exec
methods from the java.io.runtime
namespace.
Runtime rt = Runtime.getRuntime();
Process ps = rt.exec("path to my executable.exe");
Oded
2010-05-04 14:00:18
A:
Yes. Here is a link to a good blog article on how to do it: Running system commands in Java.
The gist of it is that you need to do the following:
// run the Unix "ps -ef" command
// using the Runtime exec method:
Process p = Runtime.getRuntime().exec("ps -ef");
You can pretty much put any command in there but the only gotcha that I have encountered in be aware of system environment variables like the PATH that you are running your JVM in.
Chris J
2010-05-04 14:00:40
Updated (2010) version of that article: http://www.devdaily.com/java/java-exec-processbuilder-process-1
Lord Torgamus
2010-05-04 14:05:32
Cool, nice one LT
Chris J
2010-05-04 16:42:15
A:
If you want to interact with the binary API's, use:
- Java Native Access (JNA): for loading and calling DLLs.
- Java Native Interface (JNI): for wrapping a C library in Java.
Frederik
2010-05-04 15:18:04