# Interface JavaToolchainSpec

All Superinterfaces:
  `Describable`

public interface JavaToolchainSpec extends Describable
Requirements for selecting a Java toolchain.

A toolchain is a JRE/JDK used by the tasks of a build. Tasks may require one or more of the tools (javac, java, or javadoc) of a toolchain. Depending on the needs of a build, only toolchains matching specific characteristics can be used to run a build or a specific task of a build.

Even though specification properties can be configured independently, the configuration must follow certain rules in order to form a specification.

A `JavaToolchainSpec` is considered valid in two cases:

- when no properties have been set, i.e. the specification is empty;
- when `language version` has been set, optionally followed by setting any other property.

In other words, if a vendor or an implementation are specified, they must be accompanied by the language version. An empty specification in most cases corresponds to the toolchain that runs the current build.

Usage of invalid instances of `JavaToolchainSpec` is deprecated and will be removed in the future versions of Gradle.

Since:
  6.7

- ## Method Summary

  Modifier and Type
  Method
  Description
  `default String`
  `getDisplayName()`
  Returns the display name of this object.
  `Property<JvmImplementation>`
  `getImplementation()`
  The virtual machine implementation of the toolchain.
  `Property<JavaLanguageVersion>`
  `getLanguageVersion()`
  The exact version of the Java language that the toolchain is required to support.
  `Property<Boolean>`
  `getNativeImageCapable()`
  Indicates if the toolchain should be native-image capable.
  `Property<JvmVendorSpec>`
  `getVendor()`
  The vendor of the toolchain.

- ## Method Details

  - ### getLanguageVersion

    Property<JavaLanguageVersion> getLanguageVersion()
    The exact version of the Java language that the toolchain is required to support.
    Since:
      6.7

  - ### getVendor

    Property<JvmVendorSpec> getVendor()
    The vendor of the toolchain.

    By default, toolchains from any vendor are eligible.

    Note that the vendor can only be configured if the `language version` is configured as well.

    Since:
      6.8

  - ### getImplementation

    Property<JvmImplementation> getImplementation()
    The virtual machine implementation of the toolchain.

    By default, any implementation (hotspot, j9, ...) is eligible.

    Note that the implementation can only be configured if the `language version` is configured as well.

    Since:
      6.8

  - ### getNativeImageCapable

    @Incubating Property<Boolean> getNativeImageCapable()
    Indicates if the toolchain should be native-image capable.
    Since:
      8.14

  - ### getDisplayName

    default String getDisplayName()
    Description copied from interface: `Describable`
    Returns the display name of this object. It is strongly encouraged to compute it lazily, and cache the value if it is expensive.
    Specified by:
      `getDisplayName` in interface `Describable`
    Returns:
      the display name