Creating a “hello, world” Open Liberty project in Eclipse Codewind: a user journey

Becca Bau
codewind
Published in
3 min readApr 23, 2020

I started my day off staring at a blank Eclipse Codewind Open Liberty template. If you are not familiar with Codewind, it’s a free, open source IDE extension currently available in VS Code, Eclipse, and IntelliJ (and you can use it in other configurations besides the local configuration explored in this blog, but you can read about that here). My goal today was to create a “hello, world” type application, but I had never used Open Liberty before, and had no idea where to start.

Open Liberty is an open source server runtime for Java developers that claims to bring more efficiency to building cloud-native apps and microservices, since you only run what you need (which is neat!). Because I wanted a little more understanding of the framework, I started with a guide and ended up spending about 30 minutes troubleshooting my maven configuration (or lack thereof) on my Mac. With the help of my trusty friend Google, I found that I could just install maven via Homebrew, so I ran:

brew install maven

And then I hit my second problem:

beccabau@beccabaus-mbp ~ % mvn -v
The JAVA_HOME environment variable is not defined correctly
This environment variable is needed to run this program
NB: JAVA_HOME should point to a JDK not a JRE
beccabau@beccabaus-mbp ~ % echo $JAVA_HOME
/Library/Java/Home
beccabau@beccabaus-mbp ~ % $JAVA_HOME/bin/javac -version
zsh: no such file or directory: /Library/Java/Home/bin/javac

Okay, so clearly I needed to figure out how to get my path to point to my JDK.

On my Mac, I needed to edit:

~/.bash_profile

by adding the following line:

export JAVA_HOME=$(/usr/libexec/java_home)

Then I sourced it,

source ~/.bash_profile

(see full description and other OS instructions here).

Tested and double-checked it was working:

beccabau@beccabaus-mbp ~ % echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home
beccabau@beccabaus-mbp ~ % mvn -v
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: /usr/local/Cellar/maven/3.6.3_1/libexec
Java version: 12.0.2, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk-12.0.2.jdk/Contents/Home
Default locale: en_US, platform encoding: UTF-8
OS name: “mac os x”, version: “10.15.3”, arch: “x86_64”, family: “mac”

Success! Continued on with the tutorial…

So I cloned the project and deployed the app. Then what? Well, next section showed that I could pull the Open Liberty images with Docker, so maybe I didn’t actually need to get and configure maven? 🙀

Stoically, I moved on. I used the docker command and pulled the latest images.

docker pull open — liberty

The images were pulled pretty quickly, and I followed the link to continue, which led me to containerizing a microservice and another guide! It contained maven commands, so it looked like I was on the right track. 😅

While the guides were educational and easily followed, they weren’t what I really wanted. They helped me containerize my app and get my server started, but Codewind does all that for me.

So after some more googling, I found a video that walked me through how Open Liberty files were organized, and which file to edit to make a simple app. It mostly worked out of the box, but I did have to add a few things here and there to make it work. Once I figured out what I was doing, it only took about 5–10 minutes to get the app working, as opposed to the few hours spent pouring through the guides to find myself back to where I started.

Now I have a working app, and I can make it say “hi” to me :).

If you want to see how easy it is to get started with a blank Open Liberty template, try it out in this quicklab I wrote!

--

--

Becca Bau
codewind

Just a girl, blogging about life. Also a dog-mom, twin-mom, and ultimate frisbee enthusiast. The opinions expressed here are my own.