costin 01/06/17 13:23:28 Modified: jasper34/generator/org/apache/jasper34/javacompiler JavaCompiler.java JikesJavaCompiler.java Log: addClassPath(), addDefaultClassPath() - helpers for easier use of JavaCompiler. Few logs ( to help debug Win problems ), do a getCanonicalPath() ( Nacho - let me know if it helps ) Revision Changes Path 1.4 +20 -1 jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/javacompiler/JavaCompiler.java Index: JavaCompiler.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/javacompiler/JavaCompiler.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- JavaCompiler.java 2001/06/16 20:43:24 1.3 +++ JavaCompiler.java 2001/06/17 20:23:27 1.4 @@ -72,6 +72,8 @@ * @author Costin Manolache */ public abstract class JavaCompiler { + static String CPSEP = System.getProperty("path.separator"); + protected String encoding; protected String classpath; protected String compilerPath = "jikes"; @@ -88,7 +90,8 @@ * Specify where the compiler can be found */ public void setCompilerPath(String compilerPath) { - this.compilerPath = compilerPath; + if( compilerPath != null ) + this.compilerPath = compilerPath; } @@ -106,6 +109,15 @@ this.classpath = classpath; } + public void addClassPath( String path ) { + // XXX use StringBuffer + classpath=classpath + CPSEP + path; + } + + public void addDefaultClassPath() { + addClassPath( System.getProperty("java.class.path") ); + } + /** * Set the output directory */ @@ -149,6 +161,13 @@ /** The main method - compile the source, using the previous settings. */ public boolean compile(String source) { + try { + File f=new File(source); + source=f.getCanonicalPath(); + } catch(IOException ex ) { + ex.printStackTrace(); + } + return doCompile(source); } 1.4 +15 -1 jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/javacompiler/JikesJavaCompiler.java Index: JikesJavaCompiler.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-jasper/jasper34/generator/org/apache/jasper34/javacompiler/JikesJavaCompiler.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- JikesJavaCompiler.java 2001/06/16 20:43:24 1.3 +++ JikesJavaCompiler.java 2001/06/17 20:23:27 1.4 @@ -70,7 +70,8 @@ * @author Hans Bergsten <[EMAIL PROTECTED]> */ public class JikesJavaCompiler extends JavaCompiler { - + static final int debug=0; + static final int OUTPUT_BUFFER_SIZE = 1024; static final int BUFFER_SIZE = 512; static final String q = @@ -133,6 +134,13 @@ ByteArrayOutputStream tmpErr = new ByteArrayOutputStream(OUTPUT_BUFFER_SIZE); try { + if( debug > 0 ) { + String msg=""; // Can't believe I'm writing this ! + for( int i=0; i< compilerCmd.length; i++ ) + msg+=compilerCmd[i]+ " "; + log( msg ); + } + p = Runtime.getRuntime().exec(compilerCmd); BufferedInputStream compilerErr = new @@ -162,11 +170,13 @@ return false; } + if( debug > 0 ) log( "ExitValue=" + exitValue ); boolean isOkay = exitValue == 0; // Jikes returns 0 even when there are some types of errors. // Check if any error output as well if (tmpErr.size() > 0) { isOkay = false; + if( debug > 0 ) log("tmpErr:" + tmpErr +":"); } return isOkay; } @@ -211,6 +221,10 @@ } catch (IOException ioe) { } } + } + + private static void log(String s) { + System.out.println("JikesJavaCompiler: " + s ); } }