The Java Ecosystem Explained - How Java Runs Your Code

When I first started learning Java, I was bombarded with a number of words and acronyms that all sounded the same – JDK, JRE, JVM, J2EE, J2SE and so on….. what do they all mean? This can often be intimidating for beginners, who often just skip ahead and jump straight into an IDE that hides all the details behind a pretty UI. But I think it’s important to understand the ecosystem, so that you can understand what’s going on under the hood, and build better software....

Working with Google Cloud Storage in Java - How to Upload, Download and Modify Files

Google Cloud Storage (GCS) is an object storage service that can be used to store any type of data. In this tutorial, we will learn how to work with Google Cloud Storage in your Java application, and perform common operations like uploading and downloading files. If you just want to see the code, you can go to the java-gcp-examples Github repo. Creating a Bucket You can think of a bucket as the container that all your files and data get stored in....

Working with Google Cloud SQL in Java: A Step-by-Step Guide to Creating, Connecting, and Querying Your Database

In this post, we’ll explore how to work with Google Cloud SQL in Java, including how to set up your database instance, connect to it, and perform common database operations to read and write data. What is Cloud SQL? Cloud SQL is a managed database service that allows you to run your own instance of a relational database on the cloud. Several popular database engines are supported, but for the examples in this post, we’ll be using a PostgreSQL database instance....

Spring OAuth2 Authentication

In this post we will see how we can implement OAuth2 authentication in a Java Spring Boot application. We will create a working website that can allow a user to sign in using Github authentication. If you just want to see the code, you can view the full example on Github How OAuth2 Works Let’s take a brief look at the OAuth protocol before we jump into implementation. If you’ve ever seen a dialog like this, then you’ve probably used OAuth before:...

Implementing JWT Based Authentication in Spring Boot (Using Spring Security)

In this post, we will learn how JWT(JSON Web Token) based authentication works, and how to build a Spring Boot application in Java to implement it using the Spring Security library library. If you already know how JWT works, and just want to see the implementation, you can skip ahead, or see the source code on Github The JSON web token (JWT) allows you to authenticate your users in a stateless manner, without actually storing any information about them on the system itself (as opposed to session based authentication)....

Working with PostgreSQL in Java - Using the JDBC Library

In this tutorial, we’ll learn how to connect to a Postgres database using JDBC, and run basic SQL queries in our Java application. For our Java application, we’ll be using a maven project structure. You can see the complete source code for this example on Github What Is JDBC? JDBC stands for Java Database Connectivity. It is a set of APIs that we can use to connect and execute queries on any compatible database, like PostgreSQL....

Implementing a Kafka Producer and Consumer In Java (With Full Examples) For Production

In this post we will learn how to create a Kafka producer and consumer in Java. We will also look at how to tune some configuration options to make our application production-ready. Kafka is an open-source event streaming platform, used for publishing and processing events at high-throughput. For this post, we will be using the offical Apache Kafka client library to implement our own producer and consumer in a Java application....

Deploying a Java Application to Google App Engine

In this tutorial we will learn how to deploy and run a Java Spring Boot application to Google App Engine. By the end of this tutorial, you should be able to run your own HTTP server on a public URL using the Java Spring Boot framework. App Engine Overview App Engine is a managed serverless platform that let’s you deploy and run your own applications while managing infrastructure operations. This means that you only need to manage your application code, while App Engine will take care of provisioning the actual servers, and deploying and hosting your application on those servers....

Creating a RESTful HTTP Server in Spring Boot (Java) - With Full Examples

This tutorial will explain how to run a RESTful HTTP server using the Spring Boot framework. We will learn how to build a HTTP server from scratch and create RESTful endpoints for making GET and POST requests. Next, we’ll learn how to work with different parts of the request and response, like JSON serialization, headers and HTTP status codes. By the end of this post you should have a good understanding of how to create and run your own RESTful web application....

A Complete Guide to Using Google BigQuery in Java (With Examples)

This post will highlight the basics of BigQuery and how to read, write and administer your BigQuery dataset in a Java application. BigQuery is a managed data warehouse, and is part of the Google Cloud Platform. We can use the official Java client to interact with our datasets. If you just want to see the example code, you can view it on Github BigQuery Jobs Every operation on a BigQuery dataset can be described in terms of a job....