Skip to content
JDesk
Getting started

Your first app

Scaffold a JDesk app and trace one command round trip end to end.

Scaffold from the default basic template, run it, and trace a round trip: a web page sends a name to a Java command, Java returns a typed record, and the page renders the reply.

Read the command#

@DesktopCommand("greeting.greet")
@RequiresCapability("greeting:use")
public CompletionStage<Response> greet(Request request, InvocationContext context) {
    String name = request.name() == null || request.name().isBlank()
            ? "world" : request.name().strip();
    return CompletableFuture.completedFuture(new Response("Hello, " + name + "!"));
}

The capability grant#

{ "version": 1, "grants": [ { "capability": "greeting:use", "windows": ["main"] } ] }

Clicking Greet works because the calling window holds the required capability.