Java Java Compile compile(String filename)

Here you can find the source of compile(String filename)

Description

Compiles the java program specified by filename.

License

Open Source License

Parameter

Parameter Description
filename a parameter

Return

true if it compiles, false otherwise

Declaration

public static boolean compile(String filename) 

Method Source Code

//package com.java2s;
//it under the terms of the GNU Lesser General Public License as 

import javax.tools.*;

public class Main {
    /**// w w w.j  a  v a2 s.  c o  m
     * Compiles the java program specified by filename.
     * 
     * @param filename
     * @return true if it compiles, false otherwise
     */
    public static boolean compile(String filename) {
        JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
        int compilationResult = compiler.run(null, null, null, filename);
        return compilationResult == 0;
    }
}