Package: org.gradle.api.tasks

## [Java] Class JavaExec

- org.gradle.api.tasks.JavaExec

- All Implemented Interfaces and Traits:
    JavaExecSpec

      public class JavaExec
      extends org.gradle.api.internal.ConventionTask

  Executes a Java application in a child process.

  Similar to Exec, but starts a JVM with the given classpath and application class.

       apply plugin: 'java'

       task runApp(type: JavaExec) {
         classpath = sourceSets.main.runtimeClasspath

         main = 'package.Main'

         // arguments to pass to the application
         args 'appArg1'
       }

  The process can be started in debug mode (see getDebug()) in an ad-hoc manner by supplying the `--debug-jvm` switch when invoking the build.

       gradle someJavaExecTask --debug-jvm

- - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class org.gradle.api.internal.ConventionTask` | `TASK_NAME, TASK_DESCRIPTION, TASK_GROUP, TASK_TYPE, TASK_DEPENDS_ON, TASK_OVERWRITE, TASK_ACTION`
    `class DefaultTask` | `TASK_NAME, TASK_DESCRIPTION, TASK_GROUP, TASK_TYPE, TASK_DEPENDS_ON, TASK_OVERWRITE, TASK_ACTION`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `JavaExec ()`

  - ### Methods Summary

    Methods
    Type | Name and description
    --- | ---
    `JavaExec` | `args(Object... args)` {@inheritDoc}
    `JavaExecSpec` | `args(Iterable<?> args)` {@inheritDoc}
    `JavaExec` | `bootstrapClasspath(Object... classpath)` {@inheritDoc}
    `JavaExec` | `classpath(Object... paths)` {@inheritDoc}
    `JavaExec` | `copyTo(JavaForkOptions options)` {@inheritDoc}
    `JavaExec` | `copyTo(ProcessForkOptions target)` {@inheritDoc}
    `JavaExec` | `environment(String name, Object value)` {@inheritDoc}
    `JavaExec` | `environment(Map<String, ?> environmentVariables)` {@inheritDoc}
    `void` | `exec()`
    `JavaExec` | `executable(Object executable)` {@inheritDoc}
    `List<String>` | `getAllJvmArgs()` {@inheritDoc}
    `List<String>` | `getArgs()` {@inheritDoc}
    `FileCollection` | `getBootstrapClasspath()` {@inheritDoc}
    `FileCollection` | `getClasspath()` {@inheritDoc}
    `List<String>` | `getCommandLine()` {@inheritDoc}
    `boolean` | `getDebug()` {@inheritDoc}
    `String` | `getDefaultCharacterEncoding()` {@inheritDoc}
    `boolean` | `getEnableAssertions()` {@inheritDoc}
    `Map<String, Object>` | `getEnvironment()` {@inheritDoc}
    `OutputStream` | `getErrorOutput()` {@inheritDoc}
    `protected org.gradle.process.internal.ExecActionFactory` | `getExecActionFactory()`
    `String` | `getExecutable()` {@inheritDoc}
    `List<String>` | `getJvmArgs()` {@inheritDoc}
    `String` | `getMain()` {@inheritDoc}
    `String` | `getMaxHeapSize()` {@inheritDoc}
    `String` | `getMinHeapSize()` {@inheritDoc}
    `InputStream` | `getStandardInput()` {@inheritDoc}
    `OutputStream` | `getStandardOutput()` {@inheritDoc}
    `Map<String, Object>` | `getSystemProperties()` {@inheritDoc}
    `File` | `getWorkingDir()` {@inheritDoc}
    `boolean` | `isIgnoreExitValue()` {@inheritDoc}
    `JavaExec` | `jvmArgs(Iterable<?> arguments)` {@inheritDoc}
    `JavaExec` | `jvmArgs(Object... arguments)` {@inheritDoc}
    `void` | `setAllJvmArgs(Iterable<?> arguments)` {@inheritDoc}
    `JavaExec` | `setArgs(Iterable<?> applicationArgs)` {@inheritDoc}
    `void` | `setBootstrapClasspath(FileCollection classpath)` {@inheritDoc}
    `JavaExec` | `setClasspath(FileCollection classpath)` {@inheritDoc}
    `void` | `setDebug(boolean enabled)` {@inheritDoc}
    `void` | `setDefaultCharacterEncoding(String defaultCharacterEncoding)` {@inheritDoc}
    `void` | `setEnableAssertions(boolean enabled)` {@inheritDoc}
    `void` | `setEnvironment(Map<String, ?> environmentVariables)` {@inheritDoc}
    `JavaExec` | `setErrorOutput(OutputStream outputStream)` {@inheritDoc}
    `void` | `setExecutable(Object executable)` {@inheritDoc}
    `JavaExecSpec` | `setIgnoreExitValue(boolean ignoreExitValue)` {@inheritDoc}
    `void` | `setJvmArgs(Iterable<?> arguments)` {@inheritDoc}
    `JavaExec` | `setMain(String mainClassName)` {@inheritDoc}
    `void` | `setMaxHeapSize(String heapSize)` {@inheritDoc}
    `void` | `setMinHeapSize(String heapSize)` {@inheritDoc}
    `JavaExec` | `setStandardInput(InputStream inputStream)` {@inheritDoc}
    `JavaExec` | `setStandardOutput(OutputStream outputStream)` {@inheritDoc}
    `void` | `setSystemProperties(Map<String, ?> properties)` {@inheritDoc}
    `void` | `setWorkingDir(Object dir)` {@inheritDoc}
    `JavaExec` | `systemProperties(Map<String, ?> properties)` {@inheritDoc}
    `JavaExec` | `systemProperty(String name, Object value)` {@inheritDoc}
    `JavaExec` | `workingDir(Object dir)` {@inheritDoc}

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class org.gradle.api.internal.ConventionTask` | `org.gradle.api.internal.ConventionTask#conventionMapping(java.lang.String, groovy.lang.Closure), org.gradle.api.internal.ConventionTask#conventionMapping(java.lang.String, java.util.concurrent.Callable), org.gradle.api.internal.ConventionTask#getConventionMapping(), org.gradle.api.internal.ConventionTask#setProperty(java.lang.String, java.lang.Object), org.gradle.api.internal.ConventionTask#toString(), org.gradle.api.internal.ConventionTask#compareTo(org.gradle.api.Task), org.gradle.api.internal.ConventionTask#compareTo(java.lang.Object), org.gradle.api.internal.ConventionTask#getName(), org.gradle.api.internal.ConventionTask#getActions(), org.gradle.api.internal.ConventionTask#setName(java.lang.String), org.gradle.api.internal.ConventionTask#getState(), org.gradle.api.internal.ConventionTask#getState(), org.gradle.api.internal.ConventionTask#getPath(), org.gradle.api.internal.ConventionTask#getExtensions(), org.gradle.api.internal.ConventionTask#getLogger(), org.gradle.api.internal.ConventionTask#execute(), org.gradle.api.internal.ConventionTask#configure(groovy.lang.Closure), org.gradle.api.internal.ConventionTask#configure(groovy.lang.Closure), org.gradle.api.internal.ConventionTask#getDescription(), org.gradle.api.internal.ConventionTask#leftShift(groovy.lang.Closure), org.gradle.api.internal.ConventionTask#property(java.lang.String), org.gradle.api.internal.ConventionTask#isEnabled(), org.gradle.api.internal.ConventionTask#setEnabled(boolean), org.gradle.api.internal.ConventionTask#getOutputs(), org.gradle.api.internal.ConventionTask#getOutputs(), org.gradle.api.internal.ConventionTask#onlyIf(org.gradle.api.specs.Spec), org.gradle.api.internal.ConventionTask#onlyIf(groovy.lang.Closure), org.gradle.api.internal.ConventionTask#setOnlyIf(org.gradle.api.specs.Spec), org.gradle.api.internal.ConventionTask#setOnlyIf(groovy.lang.Closure), org.gradle.api.internal.ConventionTask#setDidWork(boolean), org.gradle.api.internal.ConventionTask#getDidWork(), org.gradle.api.internal.ConventionTask#doFirst(org.gradle.api.Action), org.gradle.api.internal.ConventionTask#doFirst(groovy.lang.Closure), org.gradle.api.internal.ConventionTask#doLast(org.gradle.api.Action), org.gradle.api.internal.ConventionTask#doLast(groovy.lang.Closure), org.gradle.api.internal.ConventionTask#deleteAllActions(), org.gradle.api.internal.ConventionTask#getEnabled(), org.gradle.api.internal.ConventionTask#getAnt(), org.gradle.api.internal.ConventionTask#getLogging(), org.gradle.api.internal.ConventionTask#getLogging(), org.gradle.api.internal.ConventionTask#hasProperty(java.lang.String), org.gradle.api.internal.ConventionTask#getConvention(), org.gradle.api.internal.ConventionTask#setDescription(java.lang.String), org.gradle.api.internal.ConventionTask#getGroup(), org.gradle.api.internal.ConventionTask#setGroup(java.lang.String), org.gradle.api.internal.ConventionTask#getTaskDependencies(), org.gradle.api.internal.ConventionTask#getTaskDependencies(), org.gradle.api.internal.ConventionTask#setDependsOn(java.lang.Iterable), org.gradle.api.internal.ConventionTask#dependsOn([Ljava.lang.Object;), org.gradle.api.internal.ConventionTask#getProject(), org.gradle.api.internal.ConventionTask#setActions(java.util.List), org.gradle.api.internal.ConventionTask#getDependsOn(), org.gradle.api.internal.ConventionTask#dependsOnTaskDidWork(), org.gradle.api.internal.ConventionTask#getInputs(), org.gradle.api.internal.ConventionTask#getTemporaryDir(), org.gradle.api.internal.ConventionTask#mustRunAfter([Ljava.lang.Object;), org.gradle.api.internal.ConventionTask#setMustRunAfter(java.lang.Iterable), org.gradle.api.internal.ConventionTask#getMustRunAfter(), org.gradle.api.internal.ConventionTask#finalizedBy([Ljava.lang.Object;), org.gradle.api.internal.ConventionTask#setFinalizedBy(java.lang.Iterable), org.gradle.api.internal.ConventionTask#getFinalizedBy(), org.gradle.api.internal.ConventionTask#shouldRunAfter([Ljava.lang.Object;), org.gradle.api.internal.ConventionTask#setShouldRunAfter(java.lang.Iterable), org.gradle.api.internal.ConventionTask#getShouldRunAfter(), org.gradle.api.internal.ConventionTask#getStandardOutputCapture(), org.gradle.api.internal.ConventionTask#getAsDynamicObject(), org.gradle.api.internal.ConventionTask#setProject(org.gradle.api.Project), org.gradle.api.internal.ConventionTask#injectIntoNewInstance(org.gradle.api.internal.project.ProjectInternal, java.lang.String, java.lang.Class, java.util.concurrent.Callable), org.gradle.api.internal.ConventionTask#prependParallelSafeAction(org.gradle.api.Action), org.gradle.api.internal.ConventionTask#getOnlyIf(), org.gradle.api.internal.ConventionTask#getImpliesSubProjects(), org.gradle.api.internal.ConventionTask#setImpliesSubProjects(boolean), org.gradle.api.internal.ConventionTask#getExecuter(), org.gradle.api.internal.ConventionTask#setExecuter(org.gradle.api.internal.tasks.TaskExecuter), org.gradle.api.internal.ConventionTask#getTemporaryDirFactory(), org.gradle.api.internal.ConventionTask#addValidator(org.gradle.api.internal.tasks.execution.TaskValidator), org.gradle.api.internal.ConventionTask#getValidators(), org.gradle.api.internal.ConventionTask#appendParallelSafeAction(org.gradle.api.Action), org.gradle.api.internal.ConventionTask#isHasCustomActions(), org.gradle.api.internal.ConventionTask#getTaskActions(), org.gradle.api.internal.ConventionTask#wait(long, int), org.gradle.api.internal.ConventionTask#wait(long), org.gradle.api.internal.ConventionTask#wait(), org.gradle.api.internal.ConventionTask#equals(java.lang.Object), org.gradle.api.internal.ConventionTask#hashCode(), org.gradle.api.internal.ConventionTask#getClass(), org.gradle.api.internal.ConventionTask#notify(), org.gradle.api.internal.ConventionTask#notifyAll()`
    `class DefaultTask` | `setProperty, toString, compareTo, compareTo, getName, getActions, setName, getState, getState, getPath, getExtensions, getLogger, execute, configure, configure, getDescription, leftShift, property, isEnabled, setEnabled, getOutputs, getOutputs, onlyIf, onlyIf, setOnlyIf, setOnlyIf, setDidWork, getDidWork, doFirst, doFirst, doLast, doLast, deleteAllActions, getEnabled, getAnt, getLogging, getLogging, hasProperty, getConvention, setDescription, getGroup, setGroup, getTaskDependencies, getTaskDependencies, setDependsOn, dependsOn, getProject, setActions, getDependsOn, dependsOnTaskDidWork, getInputs, getTemporaryDir, mustRunAfter, setMustRunAfter, getMustRunAfter, finalizedBy, setFinalizedBy, getFinalizedBy, shouldRunAfter, setShouldRunAfter, getShouldRunAfter, getStandardOutputCapture, getAsDynamicObject, setProject, injectIntoNewInstance, prependParallelSafeAction, getOnlyIf, getImpliesSubProjects, setImpliesSubProjects, getExecuter, setExecuter, getTemporaryDirFactory, addValidator, getValidators, appendParallelSafeAction, isHasCustomActions, getTaskActions, wait, wait, wait, equals, hashCode, getClass, notify, notifyAll`

- - ### Constructor Detail

    - #### public JavaExec()

  - ### Method Detail

    - #### public JavaExec args(Object... args)

      {@inheritDoc}

    - #### public JavaExecSpec args(Iterable<?> args)

      {@inheritDoc}

    - #### public JavaExec bootstrapClasspath(Object... classpath)

      {@inheritDoc}

    - #### public JavaExec classpath(Object... paths)

      {@inheritDoc}

    - #### public JavaExec copyTo(JavaForkOptions options)

      {@inheritDoc}

    - #### public JavaExec copyTo(ProcessForkOptions target)

      {@inheritDoc}

    - #### public JavaExec environment(String name, Object value)

      {@inheritDoc}

    - #### public JavaExec environment(Map<String, ?> environmentVariables)

      {@inheritDoc}

    - #### @TaskAction public void exec()

    - #### public JavaExec executable(Object executable)

      {@inheritDoc}

    - #### public List<String> getAllJvmArgs()

      {@inheritDoc}

    - #### public List<String> getArgs()

      {@inheritDoc}

    - #### @InputFiles public FileCollection getBootstrapClasspath()

      {@inheritDoc}

    - #### @InputFiles public FileCollection getClasspath()

      {@inheritDoc}

    - #### public List<String> getCommandLine()

      {@inheritDoc}

    - #### public boolean getDebug()

      {@inheritDoc}

    - #### public String getDefaultCharacterEncoding()

      {@inheritDoc}

    - #### public boolean getEnableAssertions()

      {@inheritDoc}

    - #### public Map<String, Object> getEnvironment()

      {@inheritDoc}

    - #### public OutputStream getErrorOutput()

      {@inheritDoc}

    - #### @javax.inject.Inject protected org.gradle.process.internal.ExecActionFactory getExecActionFactory()

    - #### public String getExecutable()

      {@inheritDoc}

    - #### public List<String> getJvmArgs()

      {@inheritDoc}

    - #### public String getMain()

      {@inheritDoc}

    - #### public String getMaxHeapSize()

      {@inheritDoc}

    - #### public String getMinHeapSize()

      {@inheritDoc}

    - #### public InputStream getStandardInput()

      {@inheritDoc}

    - #### public OutputStream getStandardOutput()

      {@inheritDoc}

    - #### public Map<String, Object> getSystemProperties()

      {@inheritDoc}

    - #### public File getWorkingDir()

      {@inheritDoc}

    - #### public boolean isIgnoreExitValue()

      {@inheritDoc}

    - #### public JavaExec jvmArgs(Iterable<?> arguments)

      {@inheritDoc}

    - #### public JavaExec jvmArgs(Object... arguments)

      {@inheritDoc}

    - #### public void setAllJvmArgs(Iterable<?> arguments)

      {@inheritDoc}

    - #### public JavaExec setArgs(Iterable<?> applicationArgs)

      {@inheritDoc}

    - #### public void setBootstrapClasspath(FileCollection classpath)

      {@inheritDoc}

    - #### public JavaExec setClasspath(FileCollection classpath)

      {@inheritDoc}

    - #### @org.gradle.api.internal.tasks.options.Option(option = "debug-jvm", description = "Enable debugging for the process. The process is started suspended and listening on port 5005. [INCUBATING]") public void setDebug(boolean enabled)

      {@inheritDoc}

    - #### public void setDefaultCharacterEncoding(String defaultCharacterEncoding)

      {@inheritDoc}

    - #### public void setEnableAssertions(boolean enabled)

      {@inheritDoc}

    - #### public void setEnvironment(Map<String, ?> environmentVariables)

      {@inheritDoc}

    - #### public JavaExec setErrorOutput(OutputStream outputStream)

      {@inheritDoc}

    - #### public void setExecutable(Object executable)

      {@inheritDoc}

    - #### public JavaExecSpec setIgnoreExitValue(boolean ignoreExitValue)

      {@inheritDoc}

    - #### public void setJvmArgs(Iterable<?> arguments)

      {@inheritDoc}

    - #### public JavaExec setMain(String mainClassName)

      {@inheritDoc}

    - #### public void setMaxHeapSize(String heapSize)

      {@inheritDoc}

    - #### public void setMinHeapSize(String heapSize)

      {@inheritDoc}

    - #### public JavaExec setStandardInput(InputStream inputStream)

      {@inheritDoc}

    - #### public JavaExec setStandardOutput(OutputStream outputStream)

      {@inheritDoc}

    - #### public void setSystemProperties(Map<String, ?> properties)

      {@inheritDoc}

    - #### public void setWorkingDir(Object dir)

      {@inheritDoc}

    - #### public JavaExec systemProperties(Map<String, ?> properties)

      {@inheritDoc}

    - #### public JavaExec systemProperty(String name, Object value)

      {@inheritDoc}

    - #### public JavaExec workingDir(Object dir)

      {@inheritDoc}