public static TestResult execJavac(String toCompile,File dir,String jflexTestVersion){
  Project p=new Project();
  Javac javac=new Javac();
  Path path=new Path(p,dir.toString());
  javac.setProject(p);
  javac.setSrcdir(path);
  javac.setDestdir(dir);
  javac.setTarget(javaVersion);
  javac.setSource(javaVersion);
  javac.setSourcepath(new Path(p,""));
  javac.setIncludes(toCompile);
  Path classPath=javac.createClasspath();
  classPath.setPath(System.getProperty("user.home") + "/.m2/repository/de/jflex/jflex/" + jflexTestVersion+ "/jflex-"+ jflexTestVersion+ ".jar");
  ByteArrayOutputStream out=new ByteArrayOutputStream();
  PrintStream outSafe=System.err;
  System.setErr(new PrintStream(out));
  try {
    javac.execute();
    return new TestResult(out.toString(),true);
  }
 catch (  BuildException e) {
    return new TestResult(e + System.getProperty("line.separator") + out.toString(),false);
  }
 finally {
    System.setErr(outSafe);
  }
}

public static TestResult execJavac ( String toCompile , File dir , String jflexTestVersion ) { Project p = new Project ( ) ; Javac javac = new Javac ( ) ; Path path = new Path ( p , dir . toString ( ) ) ; javac . setProject ( p ) ; javac . setSrcdir ( path ) ; javac . setDestdir ( dir ) ; javac . setTarget ( javaVersion ) ; javac . setSource ( javaVersion ) ; javac . setSourcepath ( new Path ( p , "" ) ) ; javac . setIncludes ( toCompile ) ; Path classPath = javac . createClasspath ( ) ; classPath . setPath ( System . getProperty ( "user.home" ) + "/.m2/repository/de/jflex/jflex/" + jflexTestVersion + "/jflex-" + jflexTestVersion + ".jar" ) ; ByteArrayOutputStream out = new ByteArrayOutputStream ( ) ; PrintStream outSafe = System . err ; System . setErr ( new PrintStream ( out ) ) ; try { javac . execute ( ) ; return new TestResult ( out . toString ( ) , true ) ; } catch ( BuildException e ) { return new TestResult ( e + System . getProperty ( "line.separator" ) + out . toString ( ) , false ) ; } finally { System . setErr ( outSafe ) ; } }
call javac on tocompile in input dir . if tocompile is null , all * . java files below dir will be compiled .
