Better, Faster, Lighter Java with Java 12 and JHipster 6

There’s a lot going on in the Java ecosystem lately. Now that major Java versions are released every six months, it can be difficult to keep up. Personally, I develop the majority of my Java applications using Spring Boot. Because of this, I was stuck on Java 8 until Spring Boot 2.1 was released last October.

There’s a lot going on in the Java ecosystem lately. Now that major Java versions are released every six months, it can be difficult to keep up. Personally, I develop the majority of my Java applications using Spring Boot. Because of this, I was stuck on Java 8 until Spring Boot 2.1 was released last October.

Spring Boot 2.1 added Java 11 support, along with performance improvements, a new metrics implementation, new actuator endpoints, and Spring Security’s first-class OIDC support.

I was a web developer years before I became a Java developer. I’ve been developing Java for 20 years, so that’s saying a lot! If you’re a Java developer, chances are you’re baffled by the pace of change in the JavaScript world. If you think Java is hard to keep up with, try keeping up with JavaScript and its ecosystem! The good news is there’s an excellent way to keep up with both: just use JHipster.

JHipster 6 uses Spring Boot 2.1 for its backend API, which means you can use Java 11+ to develop your JHipster apps!


How Does JHipster Make Java and JavaScript Development Easier?

JHipster is one of my favorite open source projects on the planet. It’s a development platform to generate, develop, and deploy Spring Boot + Angular applications. In addition, it supports React, Vue, and creating microservice architectures with Netflix OSS, the Elastic Stack, and Docker.

Java developers tend to dislike JavaScript, but many are OK with TypeScript. Guess what? JHipster uses TypeScript for all its UI framework implementations!

JHipster makes Java and JavaScript development easier by configuring everything for you and using the latest versions of its underlying frameworks. Want to upgrade your app to use the latest versions? Simply run jhipster upgrade.

Install Java 11 or Java 12

Before you worry about installing JHipster, install Java 11. I recommend using SDKMAN! for this task. If you don’t have it installed, it’s just a command away:

curl -s "https://get.sdkman.io" | bash

Once you have it installed, you can see all the Java 11 versions available using sdk list java.

Install the OpenJDK version:

sdk install java 11.0.2-open

If you’d rather use Amazon’s Corretto, simply use 11.0.2-amzn for the name. If you want to be as hipster as possible, you can even use Java 12!

sdk install java 12.0.0-open

Azul’s Zulu is also available if you use 12.0.0-zulu for the name. |

Install JHipster 6

A beta of JHipster 6 was released today. You can install it using the command below.

npm install -g [email protected]

The npm command is part of Node.js. You’ll need to have Node 10.x to install JHipster and run useful commands. |

Create a Spring Boot + Angular App that runs on Java 11+

The most basic way to get started with JHipster is to create a new directory, cd into it, and run jhipster. You’ll be prompted to answer a number of questions about the app you’d like to create. Question range from the name of your app, to the authentication type you’d like to use, to SQL vs. NoSQL.

JHipster also has a domain language (called JDL for JHipster Domain Language) that you can use to define your app.

application {
  config {}
}

If you used the above code to create your app, it’ll use the default values:

  • baseName: jhipster
  • applicationType: monolith
  • databaseType: sql
  • etc.

You can see all the default values in JHipster’s JDL documentation. |

To generate an OAuth 2.0-enabled app with JHipster, create an app.jh file in a new project directory (e.g., ~/hipapp):

application {
  config {
    baseName hipapp
    authenticationType oauth2
  }
}

Open a terminal window and navigate to the same directory as this file. Run the following command to generate a Spring Boot API with an Angular UI.

Make sure you’re not in your home directory! Your project will be generated in the same directory as app.jh. |

jhipster import-jdl app.jh

This will create a multitude of files and install dependencies using npm install. Your terminal should look similar to the following when you run this command:

If you’d prefer to see what this command looks line in-action, you can watch the recording below.



Since you specified oauth2 as the authentication type, a Docker Compose configuration will be installed for Keycloak.

Keycloak is an Apache-licensed open source identity and access management solution. In addition to creating a src/main/docker/keycloak.yml file for Docker Compose, JHipster generates a src/main/docker/config/realm-config directory with files in it that configure Keycloak to work with JHipster out-of-the-box.


Run Your JHipster App and Log In with Keycloak

Keycloak must be running for your JHipster app to start successfully. This is because Spring Security 5.1’s first-class OIDC support is leveraged in JHipster 6.

This OIDC support includes discovery, which means that Spring Security talks to a /.well-known/openid-configuration endpoint to configure itself. I completed the migration myself and deleted more code than I added!

Start Keycloak using Docker Compose:

docker-compose -f src/main/docker/keycloak.yml up -d

If you don’t have Docker Compose installed, see these instructions for how to install it. |

Then start your application using Maven:

./mvnw

When your app is up and running, open [http://localhost:8080](http://localhost:8080) in your favorite browser and click sign in. You’ll be redirected to Keycloak, where you can enter admin/admin to log in.

Pretty slick, eh? You just created a modern single page application (SPA) that uses the latest released version of Angular! Not only that, but it uses the most secure form of OAuth 2.0 - authorization code flow.

| | If you’re confused by how OAuth 2.0 and OpenID Connect (OIDC) work together, please see What the Heck is OAuth? In short, OIDC is a thin layer on top of OAuth 2.0 that adds identity. |

Use Okta: We’re Always On!

Keycloak is an excellent project that works great for development and testing. However, if you use it in production, you’ll be responsible for maintaining it, updating it to the latest releases, and making sure it’s up 24/7. For these reasons, I recommend using Okta in production. After all, we’re always on! 😃


Create an OpenID Connect Web Application

To begin, sign up for a forever-free Okta developer account (or sign in to {yourOktaDomain} if you already have an account).

Once you’re signed in to Okta, register your client application.

Your settings should resemble the screenshot below when you’re finished.

Create an okta.env file in your project’s root directory and replace the {..} values with those from your Okta application:

export SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_OIDC_ISSUER_URI="https://{yourOktaDomain}/oauth2/default"
export SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_ID="{clientId}"
export SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_OIDC_CLIENT_SECRET="{clientSecret}"

Add *.env to your .gitignore file so this file won’t end up in your source control system. |

Create Groups and Add Them as Claims to the ID Token

JHipster is configured by default to work with two types of users: administrators and users. Keycloak is configured with users and groups automatically, but you need to do some one-time configuration for your Okta organization.

Create a ROLE_ADMIN and ROLE_USER group (Users > Groups > Add Group) and add users to them. You can use the account you signed up with, or create a new user (Users > Add Person). Navigate to API > Authorization Servers, and click on the the default server. Click the Claims tab and Add Claim. Name it groups, and include it in the ID Token. Set the value type to Groups and set the filter to be a Regex of .*. Click Create.

Start your application with the following commands:

source okta.env
./mvnw

Navigate to [http://localhost:8080](http://localhost:8080) and log in with your Okta credentials.

Isn’t it cool how Spring Boot and Spring Security make it easy to switch OIDC providers?!

CRUD with JHipster

I’ve barely scratched the service of what JHipster is capable of in this post. For example, you can create CRUD functionality for entities (with tests!) using JDL. For example, create a blog.jh file with the code below.

entity Blog {
  name String required minlength(3),
  handle String required minlength(2)
}

entity BlogEntry {
title String required,
content TextBlob required,
date Instant required
}

entity Tag {
name String required minlength(2)
}

relationship ManyToOne {
Blog{user(login)} to User,
BlogEntry{blog(name)} to Blog
}

relationship ManyToMany {
BlogEntry{tag(name)} to Tag{entry}
}

paginate BlogEntry, Tag with infinite-scroll

Then run jhipster import-jdl blog.jh in your project. The jdl-samples GitHub repository has many more examples.

Thanks for reading ❤

If you liked this post, share it with all of your programming buddies!

Follow me on Facebook | Twitter

Learn More

Java Programming Masterclass for Software Developers

Selenium WebDriver with Java -Basics to Advanced+Frameworks

Java In-Depth: Become a Complete Java Engineer!

JSP, Servlets and JDBC for Beginners: Build a Database App

JSP, Servlet, JSLT + Hibernate: A complete guide

Top 5 Java Test Frameworks for Automation in 2019

Java Hibernate Tutorial for Beginners

50+ Java Interview Questions for Programmers

Functional programming for Java developers

Java Fundamentals: Learn Java for absolute beginners |Simpliv

Java Fundamentals: Learn Java for absolute beginners |Simpliv

Java Fundamentals: Learn Java for absolute beginners

Description
This is the best course to learn to program in Java in Spanish from scratch and without any experience in this fabulous programming language. This is the first course where we will study the Fundamentals of Java, and we will take you step by step until you acquire the bases of the Java language and you can start to study more advanced Java topics.

The content is divided into perfectly structured levels, each level supported by the previous one, with the aim of adding Java knowledge incrementally and so you can focus on mastering the issues little by little and gradually. So ensure the success of your Java training.

We will also offer support for any doubts about the didactic material included in this Java Fundamentals course.

We manage a new teaching methodology that we have called Speed ​​Learning. This methodology consists of concise videos that go directly to the point to be studied, complemented by eBooks with explanations and step-by-step images (which you can print, or search for any text you need, or use for your offline study), since As we know we can not do text search within a video. In addition, our methodology includes perfectly structured and very didactic exercises that will allow you to accelerate your eLearning learning. No loss of time in videos where you have to watch the instructor codify an exercise, too much theory, little practice or anything like that. Our Speed ​​Learning methodology guarantees that in the shortest possible time you will acquire the necessary knowledge for the Java professional and working world.

The Java Fundamentals course includes the following topics for study:

Lesson 1 - Starting with Java Technology

The amazing world of Java programming

What is Java technology (from a practical approach)

Our first Java program from scratch

Lesson 2 - Variables and Operators in Java

Use of Variables in Java and what we use them for

Types of Data in Java and how they are classified

Management and Classification of operators in Java

Lesson 3 - Control statements in Java

Using the if-else structure and where to use it

Handling the switch structure and when applying it

Lesson 4 - Handling Loops in Java

Use of the for loop and its use

Using the while loop and how to apply it

Use of the do-while loop and when to use it

Lesson 5 - Object Oriented Programming

Introduction to Object Oriented Programming (OOP)

Handling Classes in Java

Use of Objects in Java

Lesson 6 - Functions in Java

Declaration of Methods or Functions in Java

Use and call of functions in Java

Lesson 7 - Data Management in Java

Using Arrays in Java

Management of Matrices in Java

Lesson 8 - Inheritance in Java

Inheritance Management in Java

Use of superclasses and subclasses in Java

Final Level Laboratory

Final Exercise where everything learned in this Level is integrated

At the end you get a certificate of having completed the Java Fundamentals course.

We wait for you on the other side.

Ing. Ubaldo Acosta

Founder of Global Mentoring

Passion for Java Technology

Who this course is for:

Anyone who wants to learn how to program in Java
Basic knowledge
Basic knowledge of PC use
Basic management of an operating system such as Windows, Mac or Linux
It is not necessary to know how to program, we will start from scratch !!!
The attitude and desire to start coding and learning Java once and for all from scratch!
What will you learn
Have the basics of the programming language with Java
You will know the basic syntax of the Java language
Manage the concept of Variables and Operators in Java
We will study Object Oriented Programming with Java
You will learn the Control Statements and Loops in Java
We will see the concept of Functions with Java
We will study the concept of Inheritance in Java
We will learn to use Arrays in java
We will handle the concept of Matrices in Java
We will learn to Design Classes in Java
We will make a final application with everything learned in the course
To know more:

Java Essentials : Learn Core Java From Basic to Advance

Java Essentials : Learn Core Java From Basic to Advance

Learn Java Programming Using Practical Assignments. Start Building Back-end Web Applications Robust Test Automation Frameworks By End Of The Course. Learn More!

Description
This is only Java related course and it's great because it covers just the right amount of Java which is needed to leaning programming, java.

This is a comprehensive yet simple course on java programming language and it concentrates on Java programming concepts.

*************************** No Prior Coding Experience Needed ***************************

This course assumes that you have no programming background. If you have some experience then, it's just a bonus point. You have never code, have some experience or have a lot of experience any other programming language, this course is one stop place for you.

Java is one of the most and useful programming languages to learn You can build back-end of web applications and build robust test automation framework. Specially for Selenium WebDriver GUI automation, Java is most popular choice and has the largest community.

Each lecture consist of a video screencast and code files

There are quizzes, homework to test your knowledge

High focus on practice and asking questions

You will also learn coding best practices

Market is never short of jobs in Java programming language, there are ample of jobs in both Java development and Automation Testing using Java.

What are you waiting for? Enroll today and learn the powerful Java language !!!

Basic knowledge
Nothing else! It’s just you, your computer and your hunger to get started today
Java concepts are covered in the course, no experience needed
Windows/MAC computer
What will you learn
You will be able to EXPLAIN, DESIGN and IMPLEMENT efficient java Programs
You will be confident to clear test automation interviews
Understand the concepts of Object Oriented Programming Language
Complete understanding of java
Expert-level knowledge of Java code (+ advanced tips and tricks used by the pros)
Suitable for beginner programmers and ideal for users who learn faster when shown
To learn more:

Fundamentos de Java: Aprende Java desde cero, sin misterios | Simpliv

Fundamentos de Java: Aprende Java desde cero, sin misterios | Simpliv

Fundamentos de Java: Aprende Java desde cero, sin misterios

Description
This is the best course to learn to program in Java in Spanish from scratch and without any experience in this fabulous programming language . This is the first course where we will study the Java Fundamentals, and we will take you step by step until you acquire the basics of the Java language and so you can start studying more advanced Java topics.

The content is divided into perfectly structured levels , each level supported by the previous one, with the aim of adding Java knowledge incrementally so that you can focus on mastering the issues little by little and gradually. So ensure the success of your Java training.

In other offer support of any doubt teaching materials included in this course Fundamentals of Java.

To make matters worse, we handle a new teaching methodology that we have called Speed ​​Learning. This methodology consists of concise videos that go directly to the point to study, complemented with eBooks with explanations and step-by-step images (which you can print, or search for any text you need, or use for your offline study), since as we know we cannot do text search within a video. In addition, our methodology includes perfectly structured and very didactic exercises, which will allow you to accelerate your eLearning learning. Without wasting time on videos where you have to watch the instructor codify an exercise, too much theory, little practice or anything like that. Our Speed ​​Learning methodology guarantees that in the shortest possible time you will acquire the necessary knowledge for the professional and professional world of Java.

The Java Fundamentals course includes the following topics of study:

Level. Java basics

Lesson 1 - Starting with Java Technology

The amazing world of Java programming
What is Java technology (from a practical approach)
Our first Java program from scratch
Lesson 2 - Variables and Operators in Java

Use of Variables in Java and what we use them for
Data types in Java and how they are classified
Operator Management and Classification in Java
Lesson 3 - Control sentences in Java

Use of the if-else structure and where to use it
Management of the switch structure and when to apply it
Lesson 4 - Cycle Management in Java

Use of the for cycle and its use
Use of the while cycle and how to apply it
Use of the do-while cycle and when to use it
Lesson 5 - Object Oriented Programming

Introduction to Object Oriented Programming (OOP)
Class Management in Java
Using Objects in Java
Lesson 6 - Functions in Java

Declaration of Methods or Functions in Java
Use and call of functions in Java
Lesson 7 - Data Management in Java

Using Arrangements in Java
Matrix Management in Java
Lesson 8 - Inheritance in Java

Inheritance Management in Java
Use of superclasses and subclasses in Java
Final Level Laboratory

Final Exercise where everything learned in this Level is integrated
At the end you get a certificate of having completed the Java Fundamentals course.

We wait for you from the other side.

Ing. Ubaldo Acosta

Founder of Global Mentoring

Passion for Java Technology

Who this course is for:

Anyone who wants to learn to program in Java
Basic knowledge
Basic knowledge of PC use
Basic operation of an operating system such as Windows, Mac or Linux
It is not required to know how to program, we will start from scratch !!!
The attitude and desire to start coding and learning Java once and for all from scratch !!!
What will you learn
Have the basics of the programming language with Java
You will know the basic syntax of the Java language
Will handle the concept of Variables and Operators in Java
We will study Object Oriented Programming with Java
You will learn Control Sentences and Cycles in Java
We will see the concept of Functions with Java
We will study the concept of Inheritance in Java
We will learn to use Arrangements in java
We will handle the concept of Matrices in Java
We will learn to Design Classes in Java
We will make a final application with everything learned in the course
To continue: