# IJavaAppResource.WithJvmArgs

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

Adds arguments to the Java Virtual Machine that runs the application.

## Remarks

Arguments are passed through the `JAVA_TOOL_OPTIONS` environment variable, which the JVM reads
however it was started -- `java -jar`, a Maven goal, a Gradle task, or a container image's own
entrypoint, including the JVM those build tools fork. Values containing spaces are quoted, because
the JVM splits this variable on whitespace.
This is also how a container image that already carries the OpenTelemetry Java agent turns it on,
since `WithOtelAgent` copies an agent from the build
context and so applies only to applications Aspire itself launches or builds:
`WithJvmArgs("-javaagent:/app/opentelemetry-javaagent.jar")`.

## Definition

```go
type IJavaAppResource interface {
    // ... omitted for brevity
    WithJvmArgs(args []string) IJavaAppResource
}
```

## Signature

```go
WithJvmArgs(args []string) IJavaAppResource
```

## Parameters

- `args` (`[]string`) -- The JVM arguments, for example `-Xmx512m`.

## Returns

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

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

## Defined on

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