Example to get System Java Compiler by calling ToolProvider.getSystemJavaCompiler(), and check sourceVersion with getSourceVersions().
package java_javacompiler;
import java.util.Set;
import javax.lang.model.SourceVersion;
import javax.tools.JavaCompiler;
import javax.tools.ToolProvider;
public class Java_JavaCompiler {
public static void main(String[] args) {
JavaCompiler javaCompiler = ToolProvider.getSystemJavaCompiler();
System.out.print(javaCompiler.toString());
Set<SourceVersion> sourceVersion;
sourceVersion = javaCompiler.getSourceVersions();
for (SourceVersion version : sourceVersion) {
System.out.print(version.name() + "\n");
}
}
}
No comments:
Post a Comment