# JavaAppHostingExtension Methods

- Package: [CommunityToolkit.Aspire.Hosting.Java](/reference/api/csharp/communitytoolkit.aspire.hosting.java.md)
- Type: [JavaAppHostingExtension](/reference/api/csharp/communitytoolkit.aspire.hosting.java/javaapphostingextension.md)
- Kind: `Methods`
- Members: `5`

Provides extension methods for adding Java applications to an `Hosting.IDistributedApplicationBuilder`.

## AddJavaApp(IDistributedApplicationBuilder, string, JavaAppContainerResourceOptions)

- Name: `AddJavaApp(IDistributedApplicationBuilder, string, JavaAppContainerResourceOptions)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<JavaAppContainerResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/67afcca30f02c18687f9c5219313710af9706630/src/CommunityToolkit.Aspire.Hosting.Java/JavaAppHostingExtension.Container.cs#L21-L38)

Adds a Java application to the application model. Executes the containerized Java app.

```csharp
public static class JavaAppHostingExtension
{
    public static IResourceBuilder<JavaAppContainerResource> AddJavaApp(
        this IDistributedApplicationBuilder builder,
        string name,
        JavaAppContainerResourceOptions options)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder` to add the resource to.
- `name` (`string`)
  The name of the resource.
- `options` ([JavaAppContainerResourceOptions](/reference/api/csharp/communitytoolkit.aspire.hosting.java/javaappcontainerresourceoptions.md))
  The [JavaAppContainerResourceOptions](/reference/api/csharp/communitytoolkit.aspire.hosting.java/javaappcontainerresourceoptions.md) to configure the Java application.

## Returns

`IResourceBuilder<JavaAppContainerResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## AddJavaApp(IDistributedApplicationBuilder, string, string, JavaAppExecutableResourceOptions)

- Name: `AddJavaApp(IDistributedApplicationBuilder, string, string, JavaAppExecutableResourceOptions)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<JavaAppExecutableResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/67afcca30f02c18687f9c5219313710af9706630/src/CommunityToolkit.Aspire.Hosting.Java/JavaAppHostingExtension.Executable.cs#L27-L47)

Adds a Java application to the application model. Executes the executable Java app.

```csharp
public static class JavaAppHostingExtension
{
    public static IResourceBuilder<JavaAppExecutableResource> AddJavaApp(
        this IDistributedApplicationBuilder builder,
        string name,
        string workingDirectory,
        JavaAppExecutableResourceOptions options)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder` to add the resource to.
- `name` (`string`)
  The name of the resource.
- `workingDirectory` (`string`)
  The working directory to use for the command. If null, the working directory of the current process is used.
- `options` ([JavaAppExecutableResourceOptions](/reference/api/csharp/communitytoolkit.aspire.hosting.java/javaappexecutableresourceoptions.md))
  The [JavaAppExecutableResourceOptions](/reference/api/csharp/communitytoolkit.aspire.hosting.java/javaappexecutableresourceoptions.md) to configure the Java application.

## Returns

`IResourceBuilder<JavaAppExecutableResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## AddSpringApp(IDistributedApplicationBuilder, string, JavaAppContainerResourceOptions)

- Name: `AddSpringApp(IDistributedApplicationBuilder, string, JavaAppContainerResourceOptions)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<JavaAppContainerResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/67afcca30f02c18687f9c5219313710af9706630/src/CommunityToolkit.Aspire.Hosting.Java/JavaAppHostingExtension.Container.cs#L49)

Adds a Spring application to the application model. Executes the containerized Spring app.

```csharp
public static class JavaAppHostingExtension
{
    public static IResourceBuilder<JavaAppContainerResource> AddSpringApp(
        this IDistributedApplicationBuilder builder,
        string name,
        JavaAppContainerResourceOptions options)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder` to add the resource to.
- `name` (`string`)
  The name of the resource.
- `options` ([JavaAppContainerResourceOptions](/reference/api/csharp/communitytoolkit.aspire.hosting.java/javaappcontainerresourceoptions.md))
  The [JavaAppContainerResourceOptions](/reference/api/csharp/communitytoolkit.aspire.hosting.java/javaappcontainerresourceoptions.md) to configure the Java application.

## Returns

`IResourceBuilder<JavaAppContainerResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## AddSpringApp(IDistributedApplicationBuilder, string, string, JavaAppExecutableResourceOptions)

- Name: `AddSpringApp(IDistributedApplicationBuilder, string, string, JavaAppExecutableResourceOptions)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<JavaAppExecutableResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/67afcca30f02c18687f9c5219313710af9706630/src/CommunityToolkit.Aspire.Hosting.Java/JavaAppHostingExtension.Executable.cs#L59)

Adds a Spring application to the application model. Executes the executable Spring app.

```csharp
public static class JavaAppHostingExtension
{
    public static IResourceBuilder<JavaAppExecutableResource> AddSpringApp(
        this IDistributedApplicationBuilder builder,
        string name,
        string workingDirectory,
        JavaAppExecutableResourceOptions options)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder` to add the resource to.
- `name` (`string`)
  The name of the resource.
- `workingDirectory` (`string`)
  The working directory to use for the command. If null, the working directory of the current process is used.
- `options` ([JavaAppExecutableResourceOptions](/reference/api/csharp/communitytoolkit.aspire.hosting.java/javaappexecutableresourceoptions.md))
  The [JavaAppExecutableResourceOptions](/reference/api/csharp/communitytoolkit.aspire.hosting.java/javaappexecutableresourceoptions.md) to configure the Java application.

## Returns

`IResourceBuilder<JavaAppExecutableResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## WithMavenBuild(IResourceBuilder<JavaAppExecutableResource>, MavenOptions?)

- Name: `WithMavenBuild(IResourceBuilder<JavaAppExecutableResource>, MavenOptions?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<JavaAppExecutableResource>`
- Source: [GitHub](https://github.com/CommunityToolkit/Aspire/blob/67afcca30f02c18687f9c5219313710af9706630/src/CommunityToolkit.Aspire.Hosting.Java/JavaAppHostingExtension.Executable.cs#L78-L126)

Adds a Maven build step to the application model.

```csharp
public static class JavaAppHostingExtension
{
    public static IResourceBuilder<JavaAppExecutableResource> WithMavenBuild(
        this IResourceBuilder<JavaAppExecutableResource> builder,
        MavenOptions? mavenOptions = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<JavaAppExecutableResource>`)
  The `ApplicationModel.IResourceBuilder`1` to add the Maven build step to.
- `mavenOptions` ([MavenOptions?](/reference/api/csharp/communitytoolkit.aspire.hosting.java/mavenoptions.md)) `optional`
  The [MavenOptions](/reference/api/csharp/communitytoolkit.aspire.hosting.java/mavenoptions.md) to configure the Maven build step.

## Returns

`IResourceBuilder<JavaAppExecutableResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## Remarks

This method adds a Maven build step to the application model. The Maven build step is executed before the Java application is started. The Maven build step is added as an executable resource named "maven" with the command "mvnw --quiet clean package". The Maven build step is excluded from the manifest file.
