Kubernetes with OpenShift World Tour: Get hands-on experience and build applications fast! Find a workshop!

Build a cloud-native Java app using Codewind and your favorite IDE

Eclipse Codewind is an open source project that makes it easier for developers to create cloud-native applications within their favorite IDE. Currently, Codewind supports Visual Studio Code, Eclipse IDE and Eclipse Che.

Codewind enables you to create applications from templates and provide support for launching, updating, testing, and debugging in Docker containers on the desktop. Codewind also supports these features on Kubernetes. You can use Codewind to move existing applications to Docker and Kuberenetes. Codewind provides validation to ensure that applications follow best practices.

This tutorial shows you how to develop a cloud-native Java applications using Codewind with both the Eclipse and VS Code IDE.

Working with Codewind on Eclipse IDE

This section shows you how to install Codewind on the Eclipse IDE and use it to build a Java application.

Prerequisites

Install Codewind

  1. Open the Eclipse IDE and navigate to Help > Eclipse Marketplace.
  2. Search for Codewind.
  3. Click Install.
  4. Finish the wizard and accept licenses as needed. Codewind Install for Eclipse
  5. When the installation is complete, restart Eclipse.
  6. In Eclipse, navigate to Window -> Show View -> Other…. -> Codewind -> Codewind Explorer. Codewind Explorer View
  7. Codewind requires the installation of additional Docker images to run. Double-click on the Codewind item in the Codewind Explorer view to complete the installation. The installation may take a few minutes to complete. Codewind Start
  8. Codewind creates a folder called codewind-workspace within your home directory (~/codewind-workspace on mac) to contain your projects.

This codewind-workspace can be accessed across editors. If you have created Codewind projects in Eclipse IDE, then those projects can be accessed from Visual Studio code’s Codewind plugin because of the codewind-workspace folder that is compatible across editors.

Project templates

Codewind provides a set of templates you can use to create a project. The templates are of different types:

  • Standard Codewind templates
  • Kabanero Collections
  • Appsody Stacks - appsodyhub

Some of the templates available now are include Go, Lagom Java, Node.js Express, Open Liberty, Python, Sprint Boot, Swift, WebSphere Liberty Microprofile, Loopback, and more.

You can create your own template and use it to create a project. Learn more in the Codewind documentation.

Create and run a microprofile project

In this tutorial, let’s create a project using the WebSphere Liberty Microprofile template available in Codewind.

  1. In the Codewind Explorer view, ensure that Codewind is running. If not, double click Codewind to start Codewind.
  2. Upon start, expand the Codewind item and right click on Local Projects and click New Project.
  3. Enter a name for the project and select WebSphere Liberty MicroProfile under templates. Click Finish to create the project. Create Project
  4. A new project is created with all the required directories and files for a cloud-native Java application. Note that Dockerfile and pom.xml are created with the necessary entries. You can edit the files to suit your needs. Project Structure
  5. The project is automatically built, deployed, and started.
  6. A context menu on the project enables you to open your application in a browser, view application and build logs, restart in debug mode, and much more. Refer to Codewind documentation for the list of context menu items and their functionality.
  7. In the Codewind Explorer view, right click on the project that was created in the above step, and click Open Application. This opens the application in the default Eclipse browser. You can start using the application. Before modification

Modify the application

It is easy to make changes to your application and deploy them. Let’s modify the Example.java file under src/main/java/application/rest/v1 so you can see how easy it is to change things.

Modify file

  1. Change the display message to Congratulations, your modified application is up and running!!!.
  2. Save the file.
  3. Wait for a few moments for the changes to automatically build and deploy.
  4. Now check the application by invoking the rest api http://localhost:xxxx/v1/example on your browser. You should get the port number from the home page of the application link from browser.

The modified message should be displayed. I hope you got a sense of how easy it is to make changes to a cloud-native application and test the changes instantly.

After modification

From there, you can also modify the application to add your business logic. When you add your business logic, you can focus solely on what’s needed for the business logic and not worry about other environmental issues while building your application.

Troubleshooting

Check Debugging Codewind projects.

Check troubleshooting guidelines for Codewind.

Working with Codewind on Visual Studio Code

Prerequisites

Install Codewind for Visual Studio Code

  1. Launch your VS Code IDE.
  2. In the menu bar, under View, click Extenstions.
  3. In the search field, type “Codewind” and hit Enter.
  4. Install Codewind by clicking on Install against the Codewind entry.
  5. Codewind requires the installation of additional Docker images to run. Choose Install when prompted to complete the installation. The installation may take a few minutes to complete. VSCode Install Codewind

    Codewind is now installed.

  6. Codewind creates a folder called codewind-workspace within your home directory (~/codewind-workspace on mac) to contain your projects.

You can access this codewind-workspace across editors. If you created Codewind projects in Eclipse IDE, then those projects can be accessed from Visual Studio code’s Codewind plugin because of the codewind-workspace folder that is compatible across editors.

Project templates in Codewind

Codewind provides a set of templates you can use to create a project. The templates are of different types:

  • Standard Codewind templates
  • Kabanero Collections
  • Appsody Stacks - appsodyhub

Some of the templates available now are include Go, Lagom Java, Node.js Express, Open Liberty, Python, Sprint Boot, Swift, WebSphere Liberty Microprofile, Loopback, and more.

You can create your own template and use it to create a project. Learn more in the Codewind documentation.

Create and run a Java project

  1. Launch your VSCode IDE.
  2. In the Explorer view, expand Codewind and then Projects.
  3. Right click on Projects and select Create New Project.
  4. Select the template you want to use to create a project. For this tutuorial, select Standard Codewind templates.
  5. Then select a template. Here select WebSphere Liberty Microprofile entry.
  6. Enter a name for the project and hit enter. A new Java microprofile project is created and can be seen in Codewind workpsace.
  7. After a few minutes, the project is in running status, after build and deploy. Once it is in running status, right click on the Python project in Codewind view and click Open App. VSCode Create Project

You will see many more options in the context menu of the application in Codewind view. Refer to the Codewind documentation for more detailed information.

Modify your application

It is very easy to make changes and deploy them. Let us modify Example.java file under src/main/java/application/rest/v1. Modify File

Before making modification, check the response for curl http://127.0.0.1:xxxx/v1/example (get port nunmber from the home page of the application link from browser, after opening the app from it’s context menu). In the above image you can see the output in the terminal view of VS Code editor.

Now, let us modify and change the display message to Congratulations, your modified application is up and running!!!. Save the file. Wait for a few moments for the changes to be automatically built and deployed. Now check the response for curl http://127.0.0.1:xxxx/v1/example. The modified message should be displayed. It is this easy to make changes to a cloud native application and test the changes instantly. Check the changes reflect in the below gif image in the tremical section of VS Code editor.

After modification

You can then go on to modify this application to add your business logic. This way you focus on just what is needed for the business logic and not worry about other environmental issues while building a cloud native application.

Troubleshooting guides for Codewind

Check troubleshooting guidelines for Codewind.

Muralidhar Chavan