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.
- When the installation is complete, restart Eclipse.
- In Eclipse, navigate to Window -> Show View -> Other…. -> Codewind -> Codewind Explorer.
- 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 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.
- A new project is created with all the required directories and files for a cloud-native Java application. Note that
Dockerfile
andpom.xml
are created with the necessary entries. You can edit the files to suit your needs. - 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.
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.
- 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.
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
- Download and install VS Code version 1.28 or later.
- Install Docker
Install Codewind for Visual Studio Code
- Launch your VS Code IDE.
- In the menu bar, under View, click Extenstions.
- In the search field, type “Codewind” and hit Enter.
- Install Codewind by clicking on Install against the Codewind entry.
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.
Codewind is now installed.
- 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 thecodewind-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
- Launch your VSCode IDE.
- In the Explorer view, expand Codewind and then Projects.
- Right click on Projects and select Create New Project.
- Select the template you want to use to create a project. For this tutuorial, select Standard Codewind templates.
- Then select a template. Here select WebSphere Liberty Microprofile entry.
- Enter a name for the project and hit enter. A new Java microprofile project is created and can be seen in Codewind workpsace.
- 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.
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
.
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.
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.