日期:2014-05-18 浏览次数:20744 次
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); int results = compiler.run(null, null, null, "C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\webapps\\test\\JavaProgramming.java"); out.println((results == 0)?"编译成功":"编译失败"); Runtime run = Runtime.getRuntime(); Process p = run.exec("java JavaProgramming"); BufferedInputStream in = new BufferedInputStream(p.getInputStream()); BufferedReader br = new BufferedReader(new InputStreamReader(in)); String s = br.readLine(); while (s.equals("hello")) out.println("the program is correct");