Skip to main content

Java Training path

Learn The Fundamentals

Java is one of the most popular and widely used programming language and also one of the 'Old School' programming language. It's fast, reliable and secure. To start off with Java, we would recommend learning the complete basics first. Which inculdes the language syntax and some of its basic features to get familiar with the language and learn its concepts. Familiarize yourself with different development environments that are used for Java i.e. Eclipse IDE or Intellij or any other that you like.

Learning Java can be overwhelming because of the volume of material about the language but be patient, learn at your own pace, don’t rush. Mastering Java is a process that takes time.

Things to cover in Java fundamentals:

  1. Basic Syntax
  2. DataTypes, Variables
  3. Conditionals and Loops
  4. Functions
  5. DataStructures
  6. OOP, Interfaces and Classes
  7. Packages
  8. Exception Handling

Here are some resources to get started. Feel free to use any other resources if that helps you learn better.

Deeper into the Java world

Java has a wide array of topics that vary in difficulty. The ones we mentioned in the previous section make up for the bare minimum to get started with coding in Java. The topics listed below are the ones require you to be confident with the fundamental concepts before moving on to the advanced stuff. Since there is a lot of content that can be listed in this section, we will only be focusing on the mostly used and important concepts.

Memory Mangement in Java

In Java, memory management is the process of allocation and de-allocation of objects. Allocation and deallocation of memory is a critical task and requires a lot of care and consideration. Java does it automatically i.e. the JVM and to be specific Garbage Collector has the role of managing memory allocation so that the programmer needs not to.

Major concepts associated with memory management in Java are:

  • JVM Memory Structure
  • How the Garbage Collector works.

Read more about memory management here : Memory management in Java

Java Streams

Java provides a new additional package in Java 8 called java.util.stream. This package consists of classes, interfaces and enum to allows functional-style operations on the elements. You can use stream by importing java.util.stream package. Features of Java stream include:

  • A stream is not a data structure instead it takes input from the Collections, Arrays or I/O channels.
  • Streams don’t change the original data structure, they only provide the result as per the pipelined methods.
  • Each intermediate operation is lazily executed and returns a stream as a result, hence various intermediate operations can be pipelined. Terminal operations mark the end of the stream and return the result.

Operations such as map, filter and sorted are classified as intermediate operations.

You can read more in detail about Java streams here: Stream In Java

Generics

Generics means parameterized types. The idea is to allow type (Integer, String, … etc., and user-defined types) to be a parameter to methods, classes, and interfaces. Using Generics, it is possible to create classes that work with different data types. An entity such as class, interface, or method that operates on a parameterized type is a generic entity.

Generics include both methods and classes. They perform as normal methods and classes with the only difference being that it contains a type parameter section.

Read more about generics here : Java-Generics

Java Web Frameworks

A web development framework is a set of resources and tools for software developers to build and manage web applications, web services and websites. Similar to other languages like JavaScript, Python, GoLang etc. Java has its own set of frameworks which allow us to develop backend APIs with ease. Most widely and one of the most popular framework used for backend Java applications is Spring/SpringBoot, which is what we will be using for this guide as well.

Spring-Boot

Spring Boot is an open source framework for building stand-alone and production ready Java applications. Spring boot is created on top of Spring and offers rapid production-ready environment which allows developers to directly concentrate on the logical side of the application rather than struggling with the configuration and setup. If you want to learn more about the difference between Spring and Spring Boot, we would suggest you to read the following article: Spring vs Spring Boot

Some salient features of Spring Boot are:

  • Create stand-alone Spring applications
  • Embed Tomcat, Jetty, or Undertow directly.
  • Provide ‘starter’ dependencies to simplify the build configuration.
  • Automatically configures Spring and 3rd party libraries whenever possible.
  • Provide production-ready features like health checks, and externalized configuration.
  • No code generation and no requirement for XML configuration.

In order to learn Spring Boot you can follow the roadmap provided below.

1. Learn Java Programming

This is a pre-requisite step so in order to be more comfortable with Spring Boot, follow the Java resources provided in initial sections or select any other source of your choice. You would need good knowledge of Java before moving on to Spring Boot.

2. Spring Framework

Since Spring boot is built on top of Spring framework, it's a good thing to know atleat the basics/fundamentals of Spring before starting with spring boot. Following are some of the concepts related to Spring fundamentals:

  1. Spring Core

  2. Spring Web

  3. AOP (Aspect Oriented Programming)

3. Spring Security

This can be considered as an important but optional step in the path to learn Spring Boot. You can go ahead learning Spring Boot without Spring Security but it's a good practice to learn all the underlying concepts before moving on to Spring Boot. Spring Security is a powerful and highly customizable authentication and access-control framework. You would need to learn the follwing concepts in Spring Security:

4. Spring Boot

We can finally start learning Spring boot. You will notice the difference straight away since all the configuration part being done manually in Spring will be handled automagically by Spring Boot. Spring boot comes with its own set of learning topics. First off you need to understand the importance of using Spring Boot. Ideally spring boot is used to create the RAD (Rapid Application Development) level application and to create microservices. Spring boot is one of the most famous frameworks to use when it comes to the Microservice architecture. In order to get started with a spring boot project, the most basic way is to use the spring initializr by visiting the start.spring.io website where you can find something like this:

Spring Initializr

Here you can select different configurations for your project i.e. Gradle or Maven as the build tool, Java version, Packaging as either JAR or WAR etc. You can also add any dependencies required for the project so that the spring initializr can generate a Pom.xml or build.gradle file depending on your choice of build tool i.e. Maven or Gradle. Note that you can always manually add the dependencies later on if you choose to not include any in the current step.

Lets include the spring web dependency and select Maven as the build tool. Hit the Generate button on the bottom. This generates a zip file with the name of the project stated in the Artifact field. Unzip and open the folder in an IDE of your choice i.e. Intellij, Eclipse etc. You will have a similar file structure as the one below:

Spring Boot Starter

This is the basic file structure followed in spring-boot applications. The DemoApplication.java is the main entry point of the application. You can add your packages in the project folder (demo in this case).

Going back to the spring initializr, if you want to check the pom.xml of build.gradle file of your project before generating it, you can click the Explore button next to the Generate button to see the contents of the specific file.

Now that we are done with setting up a basic Spring Boot application, here are some of the fundamental topics associated with spring boot framework that you should focus on from now.

  • Auto-Configuration and Manual Configuration

Spring Boot allows both auto-configuration and manually changing any of those default/auto configurations. You should learn how to handle these tasks on your own. To learn more about the difference between Spring Boot Configuration and Auto-Configuration, check out this article.

  • Properties/YAML

A common practice in Spring Boot is using an external configuration to define our properties. This allows us to use the same application code in different environments. By default, Spring Boot can access configurations set in an application.properties file, which uses a key-value format:

spring.datasource.url=jdbc:h2:dev
spring.datasource.username=SA
spring.datasource.password=password

Here each line is a single configuration, so we need to express hierarchical data by using the same prefixes for our keys. And in this example, every key belongs to spring.datasource.

Another way of configuring spring boot applications is by using YAML files. Spring profiles help enable Spring Applications to define different properties for different environments. Let's take a look at a simple YAML file that contains two profiles. The three dashes separating the two profiles indicate the start of a new document, so all the profiles can be described in the same YAML file.

spring:
config:
activate:
on-profile: test
name: test-YAML
environment: testing
enabled: false
servers:
- www.abc.test.com
- www.xyz.test.com

---
spring:
config:
activate:
on-profile: prod
name: prod-YAML
environment: production
enabled: true
servers:
- www.abc.com
- www.xyz.com

Note that this setup doesn't imply that any of these profiles will be active when we start our application. The properties defined in the profile-specific documents won't be loaded unless we explicitly indicate it; by default, the only active profile will be ‘default.‘

To learn a little more about the difference between using application properties and YAML files to configure spring boot applications, we suggest going through this blog : Using application.yml vs application.properties in Spring Boot

  • Microservices Microservices are small, loosely coupled distributed services. Microservice Architectures evolved as a solution to the scalability and innovation challenges with Monolith architectures (Monolith applications are typically huge – more than 100,000 lines of code). It permits to take a large application and break it into easily manageable small components with slightly defined responsibilities. Read more in this article: Microservices Introduction. And as it is known that Spring Boot is famous for Microservices so one should learn these things in Microservices.

Spring boot offers the spring cloud framework has different projects that help with building microservice architecture such as:

  • Spring Cloud Gateway

This project allows developers to create API gateway on top of the Spring Webflux framework. Basic purpose of an API gateway is to route the incomming client requests to the appropriate microservice and the response back to the client. We need to include the spring-cloud-starter-gateway dependency in order to use this project. To learn more about this project, you can checkout its official documentation.

  • Spring Cloud Config

Spring Cloud Config is Spring's client/server approach for storing and serving distributed configurations across multiple applications and environments. This configuration store is ideally versioned under Git version control and can be modified at application runtime. While it fits very well in Spring applications using all the supported configuration file formats together with constructs like Environment, PropertySource, or @Value, it can be used in any environment running any programming language. In order to use it your project, you would need to include the spring cloud config server dependency i.e.

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>s
  • Spring Cloud OpenFeign

OpenFeign is a declarative REST client for SpringBoot applications. Feign makes writing web service clients easier with pluggable annotation support, which includes Feign annotations and JAX-RS annotations. Also, Spring Cloud adds support for Spring MVC annotations and for using the same HttpMessageConverters as used in Spring Web. One great thing about using Feign is that we don't have to write any code for calling the service, other than an interface definition.

In order to use the Feign Client in your project, you're going to have to include the dependency

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>

We also need to add the spring-cloud-dependencies:

 <dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

Explore more about Feign client with the official documentation.

Spring Cloud contains 30+ projects so it isn't possible to list out all of them here. You can check them out in the documentation.

Although Spring does offer all these projects but due to the rise in popularity of Docker and Kubernetes in the world of Microservices, you migh not need to fully utilize these projects but its good to have some idea of all the services provided by Spring cloud in case you need to use some of it in your projects.