Java Full Stack Dev Environment

The majority of my blog so far has been about DevOps and cloud infrastructure tools such as Docker, Kubernetes, and Terraform and Jenkins. In the next series of posts, I’m going to dive into more about application development, specifically web applications from a full stack developer perspective.

Right now, let’s lay out a sample dev environment with all the tools needed to get started. We’re going to be building an application using the following:

  • JavaScript & React on the frontend

  • Java & Spring Boot on the backend

  • MariaDB as our backend database

I’m going to go over the tools that I have used. Alternatives certainly exist, so feel free to swap in whatever you are familiar with. Professionally, I use Windows to develop on, while personally, I use Linux so I’ll include instructions for both. With Linux, there may be some differences in package managers. Ensure to consult your distro’s documentation or do a search to see what packages are available to you.

JDK, MVN, NPM

The following section will go over the CLI tools nessessary for building and running our application locally. IDEs may ship pre-packed with these tools, however, it’s a good idea to install them anyway to have the ability to run applications directly from the terminal. It will also get you familar with the CLI tools in case you ever need to write a script or automation tool to automatically build and deploy your application.

Java Development Kit (JDK)

The Java Development Kit (JDK) is a comprehensive software development package provided by Oracle Corporation for creating Java applications. It serves as the fundamental toolset for Java developers, offering everything necessary to build, compile, and run Java applications. The JDK includes the Java Runtime Environment (JRE), which is essential for executing Java programs on various platforms. It also comprises the Java Compiler (javac) for converting human-readable Java source code into bytecode, a key step in the Java development process. Additionally, the JDK incorporates a range of libraries, tools, and utilities that aid in application development, debugging, and profiling. Java developers rely on the JDK to harness the power and versatility of the Java programming language for building applications across a wide array of domains, from web and mobile applications to enterprise software.

OpenJDK, on the other hand, is an open-source implementation of the Java Platform, Standard Edition (Java SE). Developed as a collaborative project by the Java community, OpenJDK aims to provide a free and open alternative to Oracle’s proprietary JDK. It includes all the core components necessary for Java application development, such as the Java Virtual Machine (JVM), libraries, and tools. OpenJDK is significant for its transparent development process, which allows developers to contribute to and modify the source code. This open nature fosters innovation and ensures compatibility with various platforms, making OpenJDK a popular choice for those who prefer open-source solutions or need Java in environments where Oracle’s licensing terms may not be ideal. It has become a key foundation for Java development, supporting a vibrant ecosystem of applications, libraries, and tools that leverage its open and collaborative nature.

Windows

To get OpenJDK installed, I used Winget which is a native Windows package manager. Run winget search openjdk and you’ll see several options from different providers. Feel free to pick whichever you prefer, as long as it is Java 17, which is the version we’ll be using for our application.

winget install AdoptOpenJDK.OpenJDK.17

After installing, confirm the java command works by running: java --version

> java --version
openjdk 17.0.8 2023-07-18
OpenJDK Runtime Environment Temurin-17.0.8+7 (build 17.0.8+7)
OpenJDK 64-Bit Server VM Temurin-17.0.8+7 (build 17.0.8+7, mixed mode, sharing)

Linux

To install the JDK on Linux, I usually consult Fedora’s guide here. OpenJDK is also available on Debian-based distro’s and you can install like this:

sudo apt install -y openjdk-17-jdk

After installing, confirm the java command works by running: java --version

> java --version
openjdk 17.0.8 2023-07-18
OpenJDK Runtime Environment
OpenJDK 64-Bit Server VM

Maven

Apache Maven is a software project management tool that makes the software development process simpler and also unifies the development process.

You can also use another project management tool called Gradle with Java projects.

The basis of Maven is the Project Object Model (POM). The POM is a pom.xml file that contains basic information about a project. There are also all the dependencies that Maven should download to be able to build a project.

Windows

There’s a few ways to install Maven: manually, by downloading the binary and manually editing your environment variables, or by checking package managers available to Windows. I used Chocolatey in this example, from an elevated PowerShell prompt:

choco install maven

After installation, run mvn -v to confirm it installed successfully. You will see your Maven version and it will output the Java Home environment variable. Something like this:

> mvn -v
Apache Maven 3.9.3
Maven home: C:\ProgramData\chocolatey\lib\maven\apache-maven-3.9.3
Java version: 17.0.8, vendor: Eclipse Adoptium, runtime: C:\Program Files\Eclipse Adoptium\jdk-17.0.8.7-hotspot
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Linux

Maven should be available in your distro’s package manager.

Debian: sudo apt install -y maven

Fedora: sudo dnf install maven

After installation, run mvn -v to confirm it installed successfully. You will see your Maven version and it will output the Java Home environment variable. Something like this:

> mvn -v
Apache Maven 3.8.7
Maven home: /usr/share/maven
Java version: 17.0.8, vendor: Debian, runtime: /usr/lib/jvm/java-17-openjdk-amd64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "6.1.0-11-amd64", arch: "amd64", family: "unix"

Node.js & NPM

Node.js is an open-source, server-side JavaScript runtime environment that allows developers to execute JavaScript code outside a web browser. Launched in 2009, Node.js has gained immense popularity for its efficiency in building scalable network applications. It operates on the V8 JavaScript engine and utilizes a non-blocking, event-driven architecture, enabling asynchronous I/O. This feature allows Node.js to handle multiple concurrent connections effectively, making it suitable for real-time applications like chatbots, gaming servers, and streaming platforms. Node.js offers a vast ecosystem of libraries and frameworks, facilitating the development of various types of applications and services. Its versatility, speed, and ability to unify front-end and back-end development make it a preferred choice for many developers.

NPM, short for Node Package Manager, is the default package manager for Node.js. It serves as a central repository for developers to access and share reusable code and libraries, referred to as packages. NPM simplifies the process of integrating third-party packages into Node.js applications, significantly enhancing development efficiency. It enables developers to manage project dependencies effortlessly, streamline updates, and easily distribute their own packages. NPM’s vast registry hosts a multitude of open-source packages, making it a valuable resource for developers seeking solutions and tools to expedite their development processes. Its command-line interface provides a straightforward way to install, manage, and deploy packages, contributing to the robustness and scalability of Node.js applications.

There is also Node Version Manager (NVM), a handy command-line tool that allows developers to manage multiple installations of Node.js on a single machine. NVM allows developers to switch between older or newer versions of Node. If you are working with old packages in a legacy codebase that requires a certain version of Node, this is very useful, otherwise you could get deprication issues that prevent you from running the application. We won’t use it here, but it is useful to know it exists in case it comes up in a professional environment.

Node.js and NPM will be required when we move onto front end development with React.

Windows

To install both Node.js and NPM run the following in an Admin PowerShell window:

choco install nodejs.install

Linux

On Linux based systems, your package manager should have both Node.js and NPM available:

sudo apt install -y nodejs npm

IDE / Code Editors

Integrated Development Environments (IDEs) are comprehensive software applications designed to streamline and enhance the process of software development. They provide programmers with a centralized platform for coding, debugging, and deploying applications, offering a suite of tools such as code editors, compilers, debuggers, and build automation tools. IDEs often include features like syntax highlighting, auto-completion, version control integration, and project management capabilities, all within a unified user interface. These environments support various programming languages and frameworks, fostering efficiency by reducing the need to switch between different tools and allowing developers to work on their projects in a more organized and productive manner.

VSCode || VSCodium

Visual Studio Code (VSCode) (while technically not an IDE) is a versatile and highly customizable source code editor developed by Microsoft. It has gained widespread popularity among developers for its user-friendly interface, extensive language support, and a vast array of extensions that enhance its functionality. Offering a rich set of features including built-in Git integration, debugging tools, intelligent code completion, and a robust extension marketplace, VSCode caters to a diverse range of programming languages and project types. Its lightweight nature coupled with powerful capabilities makes it a go-to choice for developers seeking an efficient, adaptable, and collaborative coding environment.

VSCodium is the “FLOSS” variant of VSCode. It’s exactly the same, minus the telemetry Microsoft collects by default and it has less extension support.

Feel free to use either. Personally, I switch between them depending on the device I’m on. Both VSCode and VSCodium are very useful for full stack development by adding extensions. Some people prefer doing front end work in Code/Codium, and then using a Java IDE for back end work. However, with extensions, you are able to use a single code editor for both front end and back end work. Try different tools and workflows and see what you like.

Windows

Window’s native package manager has both Code and Codium:

winget install Microsoft.VisualStudioCode

winget install vscodium

Linux

On Linux you’ll need to add a repo to your distro’s package manager in order to install Code or Codium:

VSCode on Linux

VSCodium

Extensions

Here are some extensions that are useful for front end work that are available on both Code and Codium:

  • ES7+ React/Redux/React Native Snippets

  • ESLint

  • Prettier

You will also be able to find language support extensions for various programming languages like Java.

IntelliJ

IntelliJ IDEA by Jetbrains is an integrated development environment (IDE) written in Java for developing in Java, Kotlin, Groovy, and other JVM-based languages. It provides built in functionality for Maven or Gradle projects, built in hotkeys for quickly moving through a code base, a debugger for stepping through code, and can overall speed up back end development.

To install IntelliJ, regardless of your operating system, you can get the Jetbrains Toolbox App which can also install other IDEs, like PyCharm for Python:

JetBrains Toolbox App

Windows

Simply run the executable to install the app.

Linux

tar -xzf jetbrains-toolbox-*.tar.gz
cd jetbrains-toolbox-*
./jetbrains-toolbox

you can then remove the installation files

rm- rf jetbrains-toolbox
rm jetbrains-toolbox-*.tar.gz

Spring Tools Suite

Spring Tool Suite (STS) is another IDE specifically designed for building enterprise Java applications using the Spring Framework. I don’t personally have much experience with it, but feel free to try it out.

MariaDB

MariaDB is an open-source, relational database management system (RDBMS) that forked from MySQL, designed for reliability, performance, and ease of use. Developed by the original creators of MySQL, MariaDB offers a similar syntax and structure to MySQL, making it an accessible alternative for users familiar with MySQL. However, it also introduces enhancements and additional features, such as improved performance, new storage engines, and expanded data compatibility, along with increased security measures. It supports a wide range of applications and uses, from small-scale databases to enterprise-level solutions, and its community-driven development ensures regular updates, fostering a robust and feature-rich database system for various industries and applications.

We need a local database for our back end application to interact with. The majority of modern web applications, to put it bluntly, is just a skin around a database. In other words, a web application sends queries to a database on behalf of the user and the database returns the results to the web app, which in turn displays the data to the user in a meaningful way.

Windows

To install MariaDB server on windows, go to the downloads page and get the MSI package. Run the MSI and follow the prompts. HeidiSQL, a GUI database admin tool, is included in the installation. Ensure to grab that as well.

Linux

The MariaDB setup is a bit more complex on Linux, however, it can get done with just a few commands. Go to DigitalOcean’s guide here for instructions.

This will only setup the server and cli tools. If you wish to have a GUI tool, you can get dbeaver:

wget https://dbeaver.io/files/dbeaver-ce_latest_amd64.deb

sudo dpkg -i *.deb

Wrapping Up

There are plenty of other great tools that I’ve omitted from this post for the sake of brevity. Essentially, use whatever tools keep you productive the most. In the next post, I’ll give an introduction to Spring Boot and walkthrough a basic back end application.