我有一个Main.java和Test.java类,它们要编译并在Test.java代码中运行Main.java。这是我的代码 Process pro1 = Runtime.getRuntime().exec("javac Main.java"); pro1.waitFor(); Process pro2 = Runtime.getRuntime().exec("java Main"); BufferedReader in = new BufferedReader(new InputStreamReader(pro2.getInputStream())); String line = null; while ((line = in.readLine()) != null) { System.out.println(line); }我只在Main.java中打印“ ok”,但是此代码不打印任何内容。问题是什么 ?
添加回答
举报
0/150
提交
取消