# JavaAppResource.WithMainClass

- 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`

Sets the main class an IDE launches when running or debugging this application. Has no effect on how Aspire starts the process, which is decided by the JAR path, Maven goal, or Gradle task.

## Remarks

Only affects IDE execution. When omitted, the IDE resolves the main class from the project's build
files; set it explicitly when a project declares more than one class with a `main` method.

## Definition

```go
type JavaAppResource interface {
    // ... omitted for brevity
    WithMainClass(mainClass string) JavaAppResource
}
```

## Signature

```go
WithMainClass(mainClass string) JavaAppResource
```

## Parameters

- `mainClass` (`string`) -- The fully qualified name of the class declaring `main`, for example `com.example.Application`.

## 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`
