From code to deploy : a basic Java configuration

In this short guide I would like to give you a panoramic and a work-flow idea about Java programming and explain how to build a basic and standard environment to develop Java code, in particular if you want to share your project on Github.

First of all you need a good IDE. Personally I use IntelliJ IDEA, a powerful editor developed by Jetbrains downloadable here. IntelliJ has a lot of specific features and I think the most interesting for our purpose are the Versioning Control System and the ability to inject a Framework Support into the project.

Let’s see how can we add a Framework support. Usually I manage all the dependencies with Maven, a build automation tool developed by the Apache Software Foundation.

To add the framework support to your java project you can simply click on the root project folder (project structure window on the left of IntelliJ) and select “Add framework support”: select then Maven and apply. IntelliJ will create the entire structure and your code will be placed into /src/main/java

Code is not everything, in fact in a good Java software, the testing phase is very important to produce a good Java code. The most used testing framework in the Java world is Junit. To use Junit you can simply edit the pom.xml (Project Object Model) file and add the dependency inside the “<dependencies></dependencies>” tags.

Afterwards you can create a new java class at /src/main/test and build your first test case. Here is a good guide.

IntelliJ works very well with versioning systems like Git. So the first thing to do is to create a new repo on Github, initialize a new one locally and setup the remote link to Github. You can find here a very simple Git guide. In IntelliJ you will be then able to open VCS (top menu) and commit/push the code on your Github remote repository.

Last but not the least you can enable a continuous integration mechanism for your project. CI systems allow developers to build the project automatically in a remote environment created ad hoc for your project. I personally use Travis. Travis is accessible via Github oauth authentication. Firstly you have to bind and enable the repository from the repository list. Then create a file into the root of your project named “.travis.yml ” and put inside the default string “language: java”. Push the repository.

If you have followed the previous steps, Github will trigger the Travis build process in background. If the build is ok you will find in the Travis Dashboard the information about the last build process.

At the end let’s inform other users and developers about the status of the build applying on your the Travis badge.

If you also want to deploy your software you need a Continuous Delivery tool. I recommend Heroku. This platform is well documented and supports a very wide variety of programming languages.

So, the perfect environment to collaborate on a Java project is composed of these 5 components:

  • a powerful IDE – IntelliJ IDEA
  • a flexible versioning system – Git and Github
  • an easy testing framework – Junit
  • a magical Continuous Integration engine – Travis
  • a reliable Continuous Delivery system – Heroku

And now what will be your next project?


This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.