我正在尝试通过 javacode 编译 C 程序。我做了如下。
Process process = Runtime.getRuntime().exec("C:/cygwin/bin/sh -c 'gcc HelloWorld.c -o HelloWorld.exe'");
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line, log;
log ="\n..Input..\n";
while ((line = br.readLine()) != null) {
log+=line;
log+="\n";
}
InputStream is2 = process.getErrorStream();
InputStreamReader isr2 = new InputStreamReader(is2);
BufferedReader br2 = new BufferedReader(isr2);
String line2;
log+="\n..Error..\n";
while ((line2 = br2.readLine()) != null) {
log+=line2;
log+="\n";
}
System.out.println(log);
未创建 HelloWorld.exe 并显示以下错误消息。/usr/bin/sh: gcc: 找不到命令