Example usage for javax.tools JavaCompiler getSourceVersions

List of usage examples for javax.tools JavaCompiler getSourceVersions

Introduction

In this page you can find the example usage for javax.tools JavaCompiler getSourceVersions.

Prototype

Set<SourceVersion> getSourceVersions();

Source Link

Document

Returns the source versions of the Java™ programming language supported by this tool.

Usage

From source file:Main.java

public static void main(String[] args) {
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();

    Set<SourceVersion> srcVer = compiler.getSourceVersions();
    for (SourceVersion sv : srcVer)
        System.out.println("  " + sv.name());

    int nargs = compiler.isSupportedOption(args[0]);
    if (nargs == -1)
        System.out.println("Option " + args[0] + " is not supported");
    else// w w  w. ja va  2 s .  c  om
        System.out.println("Option " + args[0] + " takes " + nargs + " arguments");
}

From source file:CompilerInfo.java

public static void main(String[] args) {
    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
    System.out.println("Supported source versions:");
    Set<SourceVersion> srcVer = compiler.getSourceVersions();
    for (SourceVersion sv : srcVer)
        System.out.println("  " + sv.name());

    int nargs = compiler.isSupportedOption(args[0]);
    if (nargs == -1)
        System.out.println("Option " + args[0] + " is not supported");
    else//from   ww w. java  2s.c  o  m
        System.out.println("Option " + args[0] + " takes " + nargs + " arguments");
}