# JavaAppResource.WithJarArtifact

- Module: [Aspire.Hosting.Java](/reference/api/go/aspire.hosting.java.md)
- Defined on: [JavaAppResource](/reference/api/go/aspire.hosting.java/javaappresource.md)
- Version: `17.0.0-preview.1.26565.2`
- Kind: `method`

Selects the JAR the generated container image runs, for projects whose build produces more than one.

## Remarks

Only affects publishing, and only when the application is built in the image. Without it the
container build selects the single JAR that is not a `-plain`, `-sources`, or
`-javadoc` artifact, and fails the build if that is ambiguous.
This takes precedence over the JAR named by the `jarPath` overload of
`AddJavaApp`, so a
resource can run one JAR locally and publish another. It has no effect on an application published
from a prebuilt JAR, because nothing is built in the image for it to select from.

## Definition

```go
type JavaAppResource interface {
    // ... omitted for brevity
    WithJarArtifact(jarPath string) JavaAppResource
}
```

## Signature

```go
WithJarArtifact(jarPath string) JavaAppResource
```

## Parameters

- `jarPath` (`string`) -- The path to the JAR produced by the build, relative to the application directory, for example `target/app.jar`.

## Returns

[`JavaAppResource`](/reference/api/go/aspire.hosting.java/javaappresource.md) -- A reference to the `IResourceBuilder`.

Returns a handle; failures surface later via `Err()`.

## Defined on

- [JavaAppResource](/reference/api/go/aspire.hosting.java/javaappresource.md) -- `handle`
