APIdia Launch Partner
Top Description Interfaces Classes Enums
module java.compiler

Package javax.tools


Provides interfaces for tools which can be invoked from a program, for example, compilers.

These interfaces and classes are required as part of the Java Platform, Standard Edition (Java SE), but there is no requirement to provide any tools implementing them.

Unless explicitly allowed, all methods in this package might throw a java.lang.NullPointerException if given a null argument or if given a list or collection containing null elements. Similarly, no method may return null unless explicitly allowed.

This package is the home of the Java programming language compiler framework. This framework allows clients of the framework to locate and run compilers from programs. The framework also provides Service Provider Interfaces (SPI) for structured access to diagnostics (javax.tools.DiagnosticListener) as well as a file abstraction for overriding file access (javax.tools.JavaFileManager and javax.tools.JavaFileObject). See javax.tools.JavaCompiler for more details on using the SPI.

There is no requirement for a compiler at runtime. However, if a default compiler is provided, it can be located using the javax.tools.ToolProvider, for example:

JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();

It is possible to provide alternative compilers or tools through the service provider mechanism.

For example, if com.vendor.VendorJavaCompiler is a provider of the JavaCompiler tool then its jar file would contain the file META-INF/services/javax.tools.JavaCompiler. This file would contain the single line:

com.vendor.VendorJavaCompiler
com.vendor.VendorJavaCompiler

If the jar file is on the class path, VendorJavaCompiler can be located using code like this:

JavaCompiler compiler = ServiceLoader.load(JavaCompiler.class).iterator().next();
JavaCompiler compiler = ServiceLoader.load(JavaCompiler.class).iterator().next();
Since
1.6

Interface Summary

Modifier and TypeInterface and Description
public interface
Diagnostic<
the type of source object used by this diagnostic
S
>

Interface for diagnostics from tools.

public interface
DiagnosticListener<
the type of source objects used by diagnostics received by this listener
S
>

Interface for receiving diagnostics from tools.

public interface
DocumentationTool

Interface to invoke Java programming language documentation tools from programs.

public interface
FileObject

File abstraction for tools.

public interface
JavaCompiler

Interface to invoke Java programming language compilers from programs.

public interface
JavaFileManager

File manager for tools operating on Java programming language source and class files.

public interface
JavaFileObject

File abstraction for tools operating on Java programming language source and class files.

public interface
OptionChecker

Interface for recognizing options.

public interface
public interface
Tool

Common interface for tools that can be invoked from a program.

Class Summary

Modifier and TypeClass and Description
public class
DiagnosticCollector<
the type of source objects used by diagnostics received by this object
S
>

Provides an easy way to collect diagnostics in a list.

public class
ForwardingFileObject<
the kind of file object forwarded to by this object
F extends FileObject
>

Forwards calls to a given file object.

public class
ForwardingJavaFileManager<
the kind of file manager forwarded to by this object
M extends JavaFileManager
>

Forwards calls to a given file manager.

public class
ForwardingJavaFileObject<
the kind of file object forwarded to by this object
F extends JavaFileObject
>

Forwards calls to a given file object.

public class
SimpleJavaFileObject

Provides simple implementations for most methods in JavaFileObject.

public class
ToolProvider

Provides methods for locating tool providers, for example, providers of compilers.

Enum Summary

Modifier and TypeEnum and Description
public enum
StandardLocation

Standard locations of file objects.