Skip to content

Add ability to pass JVM arguments to executable Java apps #887

@marshalhayes

Description

@marshalhayes

Related to an existing integration?

Yes

Existing integration

Java

Overview

AddJavaApp does not currently support passing JVM arguments to executable Java apps.

Usage example

var builder = DistributedApplication.CreateBuilder(args);

builder.AddJavaApp("app", workingDirectory: "./app",
    new JavaAppExecutableResourceOptions
    {
        ApplicationName = "app.jar",
        OtelAgentPath = "./agents",
        JvmArgs = ["-Darg=value"]
    })

The only new part here is the additional JvmArgs property.

Breaking change?

No

Alternatives

The only workaround I can think of at the moment is to build a container image for my application which sets the JVM arguments. For example:

# Dockerfile
ENV JAVA_OPTS=""
ENTRYPOINT [ "java", "$JAVA_OPTS", "-jar", "app.jar"]
// AppHost.cs
var builder = DistributedApplication.CreateBuilder(args);

builder.AddJavaApp(
    "containerapp",
    new JavaAppContainerResourceOptions
    {
        ContainerImageName = "registry/app:latest",
        OtelAgentPath = "./agents"
    })
    .WithEnvironment("JAVA_OPTS", "-Darg=value");

Additional context

No response

Help us help you

Yes, I'd like to be assigned to work on this item

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions