// Path: jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/StreamConsumer.java
// public class StreamConsumer implements Runnable {
// 
//     private final String outputPrefix;
//     private final InputStream stream;
//     private final PrintWriter log;
// 
//     public StreamConsumer(String streamName, InputStream stream, PrintWriter log) {
//         this.outputPrefix = streamName + ":";
//         this.stream = stream;
//         this.log = log;
//     }
// 
//     public void run() {
//         String output = null;
//         try {
//             output = consume(stream);
//         } catch (Exception e) {
//             e.printStackTrace();
//         }
//         log.println(outputPrefix);
//         log.println(output);
//     }
// 
//     private String consume(InputStream stream) throws IOException {
//         ByteArrayOutputStream result = new ByteArrayOutputStream(8096);
//         byte[] buffer = new byte[8096];
//         int r = -1;
//         while ((r = stream.read(buffer, 0, buffer.length)) != -1) {
//             result.write(buffer, 0, r);
//         }
//         stream.close();
//         return result.toString();
//     }
// }


import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import net.sf.jsptest.utils.StreamConsumer;

            String classpathString) {
        return new String[] { "javac", "-classpath", classpathString, "-d", outputDirectory,
                pathToJavaSource };
    }

    private String join(String[] classpath) {
        StringBuffer s = new StringBuffer(5000);
        for (int i = 0; i < classpath.length; i++) {
            if (s.length() > 0) {
                s.append(SEPARATOR);
            }
            s.append(classpath[i]);
        }
        return s.toString();
    }

    protected boolean execute(String[] commandLine) throws IOException, InterruptedException {
        Process p = Runtime.getRuntime().exec(commandLine);
        String processOutput = readOutput(p);
        boolean success = (p.waitFor() == 0);
        if (!success) {
            System.err.println(processOutput);
        }
        return success;
    }

    private String readOutput(final Process p) throws IOException {
        try {
            StringWriter output = new StringWriter();
            final PrintWriter ps = new PrintWriter(output);

// Path: jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/utils/StreamConsumer.java
// public class StreamConsumer implements Runnable {
// 
//     private final String outputPrefix;
//     private final InputStream stream;
//     private final PrintWriter log;
// 
//     public StreamConsumer(String streamName, InputStream stream, PrintWriter log) {
//         this.outputPrefix = streamName + ":";
//         this.stream = stream;
//         this.log = log;
//     }
// 
//     public void run() {
//         String output = null;
//         try {
//             output = consume(stream);
//         } catch (Exception e) {
//             e.printStackTrace();
//         }
//         log.println(outputPrefix);
//         log.println(output);
//     }
// 
//     private String consume(InputStream stream) throws IOException {
//         ByteArrayOutputStream result = new ByteArrayOutputStream(8096);
//         byte[] buffer = new byte[8096];
//         int r = -1;
//         while ((r = stream.read(buffer, 0, buffer.length)) != -1) {
//             result.write(buffer, 0, r);
//         }
//         stream.close();
//         return result.toString();
//     }
// }


// Path: jsptest-generic/jsptest-common/src/main/java/net/sf/jsptest/compiler/java/CommandLineJavac.java
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
import net.sf.jsptest.utils.StreamConsumer;

            String classpathString) {
        return new String[] { "javac", "-classpath", classpathString, "-d", outputDirectory,
                pathToJavaSource };
    }

    private String join(String[] classpath) {
        StringBuffer s = new StringBuffer(5000);
        for (int i = 0; i < classpath.length; i++) {
            if (s.length() > 0) {
                s.append(SEPARATOR);
            }
            s.append(classpath[i]);
        }
        return s.toString();
    }

    protected boolean execute(String[] commandLine) throws IOException, InterruptedException {
        Process p = Runtime.getRuntime().exec(commandLine);
        String processOutput = readOutput(p);
        boolean success = (p.waitFor() == 0);
        if (!success) {
            System.err.println(processOutput);
        }
        return success;
    }

    private String readOutput(final Process p) throws IOException {
        try {
            StringWriter output = new StringWriter();
            final PrintWriter ps = new PrintWriter(output);

            Thread stderrThread = new Thread(new StreamConsumer("STDERR", p.getErrorStream(), ps));
