A Guide for Guides: Building a Fun Java App with Tomcat & Maven with the Community Edition of IntelliJ
Tags: java
Published: 2021-11-25 21:25:20

---
title: A Guide for Guides: Building a Fun Java App with Tomcat & Maven with the Community Edition of IntelliJ
published: true
description: 
tags: java
//cover_image: 
---

Often, when reading tech articles, we long for cliff notes and tips in the margins. This is where comments and discussion threads can be especially helpful.

I've embarked on a 100 days of code challenge to become more proficient in Java, and am now 30 days. So today, my IntelliJ Ultimate license expired and I'm faced with two options: 

1. Ask my manager for a license
1. Continue with the free community edition 

Since I'm considered mainly a frontend dev on my team, asking for a license is a bit of stretch but my manager has seen enough of my full-stack experiments with Node or Python to know that I do have the potential contribute end to end features in Java too. 

I'm especially interested in building internal tools and dashboards to improve the visibility into our system. For instance, to allow our Trading team to make informed decisions about when they can launch email campaigns based on the status of multiple complex, orchestrated cron jobs that need to complete successfully before it's safe to proceed, targeting over a million customers with our latest deals.   

So I have asked, and while I wait for the green light (usually a couple days within any large enterprise) I have some time to explore the free community edition and see what I can build in the meantime with what I have. 

During this 100 day learning project, I've been bouncing between two toy apps that help me learn. One app is command line chat bot app and the other is maven-based stats app that requires Tomcat so that can run a web server to display web pages. 

This stream of consciousness post will eventually get to the steps it took me to render some html via Java. But it's less about rendering, and really only a final check before deploying to GCP. For the past few years, I've been increasingly interested in the shape of data over attempting to visualize it. I'm more interested in the complexity of how distributed systems communicate; how is the data exchanged and safe guarded so that the system can always recover and there is a sense of consistent flow where thresholds are rarely reached.   

When I tried to run this web app with the community edition, I was immediately struck by the lack of run button that was present  in the Ultimate edition. I could not figure out how to add the Tomcat server which was easy to do in the licensed version. I tried both Smart Tomcat and Tomcat Runner plugins without success on the mac.

After a googling adventure where I stumbled upon this article [Step by step Maven Tomcat WAR file deploy example](https://www.theserverside.com/video/Step-by-step-Maven-Tomcat-WAR-file-deploy-example) by Cameron Mackenzie which lead me to his github for the [Rock Paper Scissors github repo](https://github.com/cameronmcnz/rock-paper-scissors) which seemed like a fun sample project to get up and running.

Now this is the part where I step in as a guide as say that while I recommend reading his article first, you may not need to follow his step by step instructions. In fact, I tried and faltered. Instead, I did the following. 

1. brew install tomcat 
1. cd /usr/local/Cellar/tomcat/10.0.13/bin/
1. catalina start
1. go to your browser and see localhost:8080 
1. refer to Cameron's step about grabbing the roshambo.war file from the specific branch
1. paste that war into /usr/local/Cellar/tomcat/10.0.13/libexec/webapps
1. notice that when you paste in the war, it creates a folder and expands its contents
1. go back the browser and view localhost:8080/roshambo
1. rename roshambo folder to rps and try to view it again

I'll also [credit this youtube](https://www.youtube.com/watch?v=8xjWToEoNck) which tipped me off on how to copy the war into Tomcat.  

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0gpafovo2gr97waq1jjw.png)

And voila! I have a working rock paper scissors app in my browser which is gives me enough confidence to return my app and continue experimenting.   

Now, the final part that I wanted today was the ability for Maven to build the war file and move it Tomcat. And thanks to this [stackoverflow thread](https://stackoverflow.com/questions/369639/how-to-copy-war-to-tomcats-webapps-directory-using-maven) I was able to tweak the ship for my mac: 

```
<plugin>
  <artifactId>maven-war-plugin</artifactId>
  <version>3.2.0</version>
  <configuration
<outputDirectory>/usr/local/Cellar/tomcat/10.0.13/libexec/webapps/</outputDirectory>
  </configuration>
</plugin>
``` 

Simply calling `mvn package` performs the desired results. I decided to change a few values and learn a bit about the system.   

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3zaz0vraqdop117rgg47.png)

Again, all I want to use Tomcat as final check for little UI that I have, and mainly use IntelliJ for the big services backing it. I've worked alongside many devs who would be entirely comfortable with no UI whatsoever but I prefer at least some parse, minimal controls that empower non-technical people to make mighty leaps of faith.