01: // JDKCompiler.java
02: // $Id: JDKCompiler.java,v 1.4 2000/08/16 21:37:43 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1998.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.jigsaw.pagecompile;
07:
08: import java.io.OutputStream;
09: import java.io.PrintStream;
10:
11: import sun.tools.javac.Main;
12:
13: /**
14: * @version $Revision: 1.4 $
15: * @author Benoît Mahé (bmahe@w3.org)
16: */
17: public class JDKCompiler implements PageCompiler {
18:
19: /**
20: * compile some files.
21: * @param args The compiler arguments (files+options)
22: * @param out The outputStream, the compiler will write its output
23: * in it.
24: * @return false if compilation failed.
25: */
26: public boolean compile(String args[], OutputStream out) {
27: if (out == null)
28: out = System.out;
29: int len = args.length;
30: String newargs[] = new String[len + 2];
31: System.arraycopy(args, 0, newargs, 0, len);
32: newargs[len] = "-classpath";
33: newargs[len + 1] = System.getProperty("java.class.path");
34: return (new Main(out, "compiler")).compile(newargs);
35: }
36:
37: //testing only
38: public static void main(String args[]) {
39: (new JDKCompiler()).compile(args, null);
40: }
41:
42: }
|