private static void generateJavaFiles ( final StatusUpdateTemplate template , final String workingPath ) throws FileNotFoundException { final String javaPath = WORKING_DIR + template . getName ( ) + ".java" ; final File javaFile = new File ( javaPath ) ; final String [ ] optionsAndSources = { "-classpath" , workingPath , "-proc:none" , "-source" , "1.7" , "-target" , "1.7" , javaPath } ; // write java file final PrintWriter writer = new PrintWriter ( javaFile ) ; writer . write ( template . getJavaCode ( ) ) ; writer . flush ( ) ; writer . close ( ) ; // delete previous class file final File classFile = new File ( WORKING_DIR + template . getName ( ) + ".class" ) ; classFile . delete ( ) ; // compile java file to class file final JavaCompiler compiler = ToolProvider . getSystemJavaCompiler ( ) ; compiler . run ( System . in , System . out , System . err , optionsAndSources ) ; // delete java file javaFile . delete ( ) ; }
generate a java class file for the template specified