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
Download and install the latest Eclipse IDE for Java EE Developers or use an existing installation. Eclipse IDE versions 4.11.0 onwards support Codewind.
Install Docker
Install Codewind
Open the Eclipse IDE and navigate to Help > Eclipse Marketplace.
Search for Codewind.
Click Install.
Finish the wizard and accept licenses as needed. Codewind Install for Eclipse
When the installation is complete, restart Eclipse.
In Eclipse, navigate to Window -> Show View -> Other…. -> Codewind -> Codewind Explorer. Codewind Explorer View
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
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.

In the Codewind Explorer view, ensure that Codewind is running. If not, double click Codewind to start Codewind.
Upon start, expand the Codewind item and right click on Local Projects and click New Project.
Enter a name for the project and select WebSphere Liberty MicroProfile under templates. Click Finish to create the project. Create Project
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
The project is automatically built, deployed, and started.
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.
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

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 automatically build and deploy.
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.

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注