Develop with Java Workshop SDKs on Ubuntu¶
This tutorial provides basic guidance on using the Java Workshop SDKs for development environments on Ubuntu with the Workshop tool. It shows how to create a “Hello, World!” program, explains how to build projects using Gradle or Maven, and goes in-depth with an example using the petclinic application.
For instructions on how to install Workshop and related tooling, see the dedicated guide on how to Get started with workshops. This article assumes that the suggested tooling has been installed. There is no need to install Java or related tooling, as they are installed through the examples process.
Currently supported Java Workshop SDKs¶
The following Workshop SDKs are available for the Java ecosystem:
Getting started with Java Workshop SDKs¶
To get started using these SDKs, install Workshop and its prerequisites to make sure it runs:
dev@ubuntu:~$ dev@ubuntu:~$ Before initializing a workshop, search the SDK Store to confirm that the SDKs exist and get information about the publisher and the available versions.
Confirm/search for available SDKs:
dev@ubuntu:~$Inspect SDK release information:
dev@ubuntu:~$
Creating a Java Workshop using OpenJDK¶
Compile a Java application directly using tools from the openjdk workshop SDK.
Prerequisites
Procedure
Initialize the applications workshop definition with the
openjdkSDK:dev@ubuntu:~$This command writes the definition to the
.workshop/openjdk-example.yamlfile with theopenjdkSDK pinned to the21/stablechannel..workshop/openjdk-example.yaml¶name: openjdk-example base: ubuntu@24.04 sdks: - name: openjdk channel: 21/stable
Note
The choice of
openjdk-exampleas the name of the workshop here is arbitrary; however, it could reflect the expected environment context. For example, a project could have development, production, and testing workshop definitions to sandbox internal and external release environments whilst keeping them replicable for all users.Create a “Hello, World!” application in a file named
App.java:App.java¶public class App { public String getGreeting() { return "Hello, World!"; } public static void main(String[] args) { System.out.println(new App().getGreeting()); } }
To get the workshop ready for use, launch it and confirm the runtime information matches the definition file:
Prepare workshop after initialization:
dev@ubuntu:~$View information about the workshop:
dev@ubuntu:~$This prepares the workshop by automatically pulling and installing the defined SDKs, after which it starts the workshop container. If any changes are made to the
.workshop/openjdk-example.yamlfile, the workshop can be refreshed using theworkshop refreshcommand.Note
To stop the workshop environment from running, use
workshop stop. To then make the workshop ready for use again, start it with theworkshop startcommand.
Compile the class file in the
outdirectory within the workshop:dev@ubuntu:~$Execute the compiled program from within the workshop:
dev@ubuntu:~$This prints “Hello, World!” to the workshop console.
Creating a Java Workshop using Maven¶
Set up and build a new Java project using the maven workshop SDK.
Prerequisites
Procedure
Initialize the applications workshop definition with the
openjdkandmavenSDKs:dev@ubuntu:~$This command writes the definition to the
.workshop/maven-example.yamlfile with the SDKs pinned to their respective channels..workshop/maven-example.yaml¶name: maven-example base: ubuntu@24.04 sdks: - name: openjdk channel: 21/stable - name: maven channel: 3.9/stable
To get the workshop ready for use, launch it and confirm the runtime information matches the definition file:
Prepare workshop after initialization:
dev@ubuntu:~$View information about the workshop:
dev@ubuntu:~$
Enter the workshop using the
workshop execcommand:dev@ubuntu:~$Create a new Java project using the
archetype:generateMaven sub-command from within the workshop:dev@ubuntu:~$Press Enter when prompted to confirm your selection. This creates a new project using the Maven Quickstart Archetype and sets up a basic project structure that is replicated between the workshop environment and your host directory.
Change to the project directory and package the application:
dev@ubuntu:~$dev@ubuntu:~/helloworld$
Creating a Java Workshop using Gradle¶
Set up and build a new Java project using the gradle workshop SDK.
Prerequisites
Procedure
Initialize the applications workshop definition with the
openjdkandgradleSDKs:dev@ubuntu:~$This command writes the definition to the
.workshop/gradle-example.yamlfile with the SDKs pinned to their respective channels..workshop/gradle-example.yaml¶name: gradle-example base: ubuntu@24.04 sdks: - name: openjdk channel: 21/stable - name: gradle channel: 9/stable
To get the workshop ready for use, launch it and confirm the runtime information matches the definition file:
Prepare workshop after initialization:
dev@ubuntu:~$View information about the workshop:
dev@ubuntu:~$
Enter the workshop using the
workshop execcommand:dev@ubuntu:~$Create a new Java project using the
gradle initcommand from within the workshop:dev@ubuntu:~$dev@ubuntu:~/helloworld$Press Enter when prompted for the Java version. This creates a new project that includes a “Hello, World!” application and a unit test, mounted between the workshop environment and your host directory.
Change to the project directory to build and run the project using the generated Gradle wrapper:
dev@ubuntu:~$
Advanced example with petclinic¶
Set up and build the petclinic sample application using the Java Workshop SDKs.
Prerequisites
Procedure
Initialize the
petclinicproject directory by cloning the target repository:dev@ubuntu:~$dev@ubuntu:~$Initialize the applications workshop definition with your choice of SDKs. For this example, use the
openjdkandmavenSDKs:dev@ubuntu:~$This command writes the definition to the
.workshop/petclinic-example.yamlfile with the SDKs pinned to their respective channels.Extend the
.workshop/petclinic-example.yamlconfiguration to include a slot and plug pair that exposes the application over thelocalhost:8080endpoint, and some actions to manage the application:.workshop/petclinic-example.yaml¶name: petclinic-example base: ubuntu@24.04 sdks: - name: openjdk channel: 21/stable - name: maven channel: 3.9/stable slots: petclinic: interface: tunnel endpoint: localhost:8080 - name: system plugs: petclinic: interface: tunnel endpoint: localhost:8080 actions: build: mvn clean package # Note: We use `mvn` over the `./mvnw` wrapper start: mvn spring-boot:run # to use our custom defined channel version
The plug and slot pair defined above are the interfaces that specify how to communicate and share resources. This allows each workshop to operate in its own isolated environment, whilst still allowing controlled interactions between the SDKs and the host. In our example, we first define a slot for Maven, which provides the capability to expose a desired network endpoint through the tunnel interface.
Secondly, the example defines a tunnel plug that consumes the capability provided by the Maven slot. Since the plug is defined for the system SDK, this routes the Maven endpoint to the host endpoint and allows us to access the application from the host. This can be seen in the diagram below, where our interface pairing allows the client access to the application in the workshop.
The following diagram shows the interface pairing that gives the client access to the application in the workshop:

After adding the changes above, launch the workshop and confirm that the runtime information matches the workshop definition:
Prepare workshop after initialization:
dev@ubuntu:~$View information about the workshop:
dev@ubuntu:~$And start the application using Maven:
dev@ubuntu:~$
Alternatively, execute commands directly inside the environment:
dev@ubuntu:~$dev@ubuntu:~$Since we have exposed the application through the configured slot/plug pairing, we can then see the application in any browser on the host machine at the
http://localhost:8080endpoint.Modify the workshop definition to use
gradleinstead ofmavenby updating the actions to work with Gradle instead:.workshop/petclinic-example.yaml¶name: petclinic-example base: ubuntu@24.04 sdks: - name: openjdk channel: 17/stable - name: gradle channel: 8/stable slots: petclinic: interface: tunnel endpoint: localhost:8080 - name: system plugs: petclinic: interface: tunnel endpoint: localhost:8080 actions: build: gradle build # Note: We use 'gradle' over the './gradlew' wrapper start: gradle bootRun # since we want to use our defined channel version
Refresh the workshop to now use the
gradleSDK instead of themavenSDK:Refresh the environment with Gradle:
dev@ubuntu:~$Confirm that information has changed:
dev@ubuntu:~$And start the application using Gradle:
dev@ubuntu:~$
Note
For the petclinic project, make sure that the combination of openjdk and the chosen build tool versions are compatible.