DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Because the DevOps movement has redefined engineering responsibilities, SREs now have to become stewards of observability strategy.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Related

  • Digging Into Sockets With Java Flight Recorder
  • A Systematic Approach for Java Software Upgrades
  • Building a Simple RAG Application With Java and Quarkus
  • Dust Actors and Large Language Models: An Application

Trending

  • Rust, WASM, and Edge: Next-Level Performance
  • Enforcing Architecture With ArchUnit in Java
  • Event-Driven Microservices: How Kafka and RabbitMQ Power Scalable Systems
  • How to Create a Successful API Ecosystem
  1. DZone
  2. Coding
  3. Java
  4. Java: It’s Time to Move Your Application to Java 11

Java: It’s Time to Move Your Application to Java 11

By 
Otavio Santana user avatar
Otavio Santana
DZone Core CORE ·
Mar. 19, 20 · Opinion
Likes (7)
Comment
Save
Tweet
Share
18.6K Views

Join the DZone community and get the full member experience.

Join For Free

In the past few years, several exciting things have happened in the Java world, among them is certainly the new version control. Previously, it could take anywhere between two or three years for a new version to be released. Now, there's a new cadence every six months in addition to the LTS for new versions of the JVM. Currently, there is already work to deliver Java 14, however, as the latest research reveals, the use of Java 8 remains very strong for the market. This post aims to encourage and discuss the reasons for upgrading to Java 11, the current Java LTS.

There are several Java surveys that show that Java 8 is still the most popular version among developers, such as the SNYK that shows Java 8 with 64% against 25% in Java 11 and Eclipse Foundation where the number is even more significant with 80% with Java 8 against 20% with Java 11.

Indeed, Java 8 brings terrific features, such as Lambda, new date and time, and Streams that make Java 8 the most loved version for Java developers. Furthermore, the release every six months is scary for some developers, but we also have the Long term support version that works, and it happens every three years, thus either we can release every six months or jump LTS to LTS three years.

We'll talk about the current LTS version and why we should move to it. The first reason for security purposes. There is no Java 8 public release anymore. Thus, Java 8 won't be continued to be patched for common vulnerabilities and exposures, CVE.

The second reason concerns performance. In the Java 11 (and since Java 9), there have been several improvements, such as:

  • Next LTS version.

  • Full support for Linux containers.

  • Support parallel full garbage collection on G1.

  • Free Application Class-Data Sharing feature.

  • Heap allocation on alternative memory devices.

  • New default set of root authority certificates.

  • New ZGC and Epsilon garbage collectors.

  • Ahead-of-time compilation and GraalVM.

  • Transport Layer Security (TLS) 1.3.

 (You can read more about these on this blog.)

We can see several benchmarks that show an improvement of around 20% with these changes. Furthermore, we don't need to update the code to move from Java 8; we can run Java 8 code on the Java 11 JVM, and we can see some improvements such as memory and boot time.

This post won't talk about the news features of Java 11, but we'll focus on the benefits of moving to Java 11. To keep your code working, we need to be aware of the JEP 320: Remove the Java EE and CORBA Modules. If you are using dependencies you need to add that dependency in your favorite build tools. There are several tips about migration on this post.

Update a Java 8 Application

To show how easy it is to migrate a Java 8 project to Java 11, let's take a look at an example. The first our first post about Hello world at Platform.sh with Spring.

To update the application, we need to update a single file: the platform.app.yaml file. So, we take this file:

YAML
 




x
14


 
1
name: app
2
type: "java:8"
3

          
4
disk: 1024
5

          
6
hooks:
7
  build: mvn clean install
8

          
9
relationships:
10
  database: "database:mysql"
11
web:
12
  commands:
13
    start:  java -jar target/spring-boot-maven-mysql.jar --server.port=$PORT
14

          



We'll update this file to Java 11. Therefore, Platform.sh will generate a container using Java 11 version instead of Java 8.

YAML
 




xxxxxxxxxx
1
14


 
1
name: app
2
type: "java:11"
3

          
4
disk: 1024
5

          
6
hooks:
7
  build: mvn clean install
8

          
9
relationships:
10
  database: "database:mysql"
11
web:
12
  commands:
13
    start:  java -jar target/spring-boot-maven-mysql.jar --server.port=$PORT
14

          



The application is now ready, so it’s time to move it to the cloud with Platform.sh using the following steps:

  • Create a new free trial account.

  • Sign up with a new username and password, or login using a current  GitHub, Bitbucket, or Google account. If you use a third-party login, you’ll be able to set a password for your Platform.sh account later.

  • Select the region of the world where your site should live.

  • Select the blank template.

After this, Platform.sh will provision the whole infrastructure for you and offer a Git remote repository. Before access, remember to set your SSH keys. You only need to write your code — including a few YAML files that specify your desired infrastructure — then commit it to Git and push.

Shell
 




xxxxxxxxxx
1


 
1
git remote add platform <platform.sh@gitrepository>
2
git commit -m "Initial project"
3
git push -u platform master
4

          



In the next sample, let's use a Jakarta EE sample with the Payara server. We'll use the template from Platform.sh. We'll do a similar procedure with Spring in the application file. So, we'll take the application file:

YAML
 




xxxxxxxxxx
1
10


 
1
name: app
2
type: "java:8"
3
disk: 1024
4
hooks:
5
    build:  mvn clean package payara-micro:bundle
6

          
7
web:
8
    commands:
9
        start: java -jar -Xmx512m target/microprofile-microbundle.jar --port $PORT
10

          



Then, update the type to "java:11". Now, we'll run the application with Java 11.

YAML
 




xxxxxxxxxx
1
10


 
1
name: app
2
type: "java:11"
3
disk: 1024
4
hooks:
5
    build:  mvn clean package payara-micro:bundle
6

          
7
web:
8
    commands:
9
        start: java -jar -Xmx512m target/microprofile-microbundle.jar --port $PORT
10

          



Whether it's performance improvements that containers benefit a lot from or the fact that security updates are no longer made in version 8, I hope you see a benefit to upgrading to Java 11. In the next part of this series, we will talk a little about the API improvements that exist within Java 11.


Java (programming language) application IT

Opinions expressed by DZone contributors are their own.

Related

  • Digging Into Sockets With Java Flight Recorder
  • A Systematic Approach for Java Software Upgrades
  • Building a Simple RAG Application With Java and Quarkus
  • Dust Actors and Large Language Models: An Application

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!