java Processbuilder - exec a file which is not in path on OS X
Okay i'm trying to make ChucK available in exported Processing sketches, i.e. if i export an app from Processing, the ChucK VM binary will be executed from inside the app. So as a user of said app you don't need to worry about ChucK being in your path at all.
Right now i'm generating and executing a bash script file, but this way i don't get any console output from ChucK back into Processing:
#!/bin/bash
cd "[to where the Chuck executable is located]"
./chuck --kill
killall chuck # just to make sure
./chuck chuckScript1.ck cuckScriptn.ck
then
Process p = Runtime.getRuntime().exec("chmod 777 "+scriptPath);
p = Runtime.getRuntime().exec(scriptPath);
This works but i want to run ChucK directly from Processing instead, but can't get it to execute:
String chuckPath = "[folder in which the chuck executable is located]"
ProcessBuilder builder = new ProcessBuilder
(chuckPath+"/chuck", "test.ck");
final Process process = builder.start();
InputStream is = process.getInputStream();
开发者_C百科 InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while((line = br.readLine()) != null) println(line);
println("done chuckin'! exitValue: " + process.exitValue());
Sorry if this is newbie style :D
ProcessBuilder builder = new ProcessBuilder
(chuckPath+"/chuck", chuckPath+"/test.ck");
the args all need an absolute path.
精彩评论