Michael Bryan

Michael Bryan

1560829027

The Java Platform Module System

Although Java 9 is not the latest JDK release (to be more specific, it was released back in 2017), it was the biggest update in the history of the JDK. Despite that, most Java programmers hardly mention its most significant feature — the Java Platform Module System.

This is primarily because most business applications still use Java 8. For now, it has demonstrated stability and newer releases need time to spread across the IT world.

That’s why I decided to write this article. In the future, if you facing this technology, you will be able to get a flying start.

Java 9: A Historical Perspective

  • 2006: Java 6 by Sun Microsystems (compare to previous releases it was fairly minor)
  • 2011: Java 7 was the first Oracle release; it contained far fewer features than anticipated. Mainly low-level API changes.
  • 2014: Java 8: Serious innovations, specifically lamdas and streams.
  • 2017: The Java 9 release was postponed several times due to setbacks regarding the module system implementation. But finally, in September 2017, it was released.

Since Java 9, there has been a new release every six months. Before that, there was only one release once the planned features were complete.

The Java Platform Module System

One of the biggest changes in Java, ever.

It affects the followings:

  • **Language **(new features and keywords)
  • **Compiler **(needs to translate new features and must know module boundaries)
  • **JVM **(All module metadata around modules are preserved in a binary format and loaded by the JVM)
  • **Tooling **(IDEs, libraries need to adapt to modularity)

Reasons Why the Module System Added to the Language

There are a few reasons why modularizing was necessary.

Modularize the JDK Itself

The Java JDK is over 20 years old, and it was one big file. It was hardly maintainable. Everything was chained together and they would like to work down this technical debt to make it maintainable again.

Modularize Applications

Along with the modularized JDK, developers should modularize their applications as well. Although, it is important to note that modularization is optional!

If you switch to Java 9, you can keep using Java as you used to, or you can switch to the module system and start to modularize your application and make it more maintainable.

Although you will still run on modularized JDK, this can still affect your code!

Before the Modular JDK

  • One huge library: rt.jar (runtime.jar)
  • This library was only grown and nothing removed from it in the last 20 years.
  • Many inner libraries have been used by outer applications even that they do not suppose to do that, but there was no way to restrict that.

The Modular JDK: Explicit Dependencies

This is how the new Java platform looks like.

They divided JDK into more than 90 separate modules. Each module encapsulates its own piece of functionality of the Java runtime library. The picture above represents the dependencies between the modules.

The most important one is the *java.base *module. It represents the most basic classes of the language, like streams, strings, and objects. Since this module is essential, all other modules depend on this library.

Here, we see a more complex graph about the different libraries and how they connect to each other. The ones with names starting with *java *indicate that these are part of the Java SE specifications.

In the dependency graph above, you can also see two modules in blue; these do not start with java but jdk. These are JDK-specific.

You may notice that all arrows are pointing down. This means that there are no circular dependencies. Hence, it has very clean modularization.

Let’s see some examples:

*Corba *is ancient technology, and it’s still part of the JDK. However, it is isolated into its module. This means that unless your application has a dependency on java.corba, this old technology won’t get in.

Another module in this graph you may be more familiar: Java.desktop. It contains all the swing GUI toolkits of the Java platform. Hence, your application doesn’t need any of these GUI dependencies; and you do not need to reference the java.desktop module.

The Modular JDK Advantages

Increased Security

That’s a one we didn’t touch upon yet. This is due that the fact a module can explicitly expose some of the packages and strongly encapsulate other packages. As I mentioned earlier, there are many internal implementations in classes in the JDK that need to be public because it is used among different packages, but at the same time, they should not be used outside of JDK. These later ones are encapsulated.

Reduced Footprint

If you start, make modularized applications on top of the Modularized JDK. You do not need to scan and load all the classes that the *rt.jar *contains, which you cannot avoid before you can only include the necessary modules.

Easy Deprecation

Having clearly separate modules also helps deprecation. The idea is that, at some point, a module can be marked as deprecated. Every application that uses that module should look to another solution. After that, in the next major release, it can be removed from the JDK.

It is already happening because in Java 9, the *java.corba *module has been marked as deprecated.

Future Proof

The deprecation example is true from the other way as well. It is much easier to ship new features to the language. They can add incubator modules, and if it is stable, it can be converted to a real module with the next major release.

There is an example as well as the *jdk.incubator.httpclient *module.

What Is a Module?

Now, we see the new modularized JDK, but a big question remains: What exactly is a module?

A module has a name; it has a distinct identity; it has **groups **related code. Furthermore, it fully self-contained, which means that it needs to contain everything to do its functions. If it hasn’t, it must reference another module from the library.

Module Descriptors

The below image shows how a module builds up.

This structure is described in the module-info.java.

module java.base {
  exports java.lang;
  exports java.util;
  exports java.io;
  //etc.
}

We do not see any external module dependencies here because *java.base *do not reference any.

Let us see another example.

The *java.sql *references to two other modules, these are marked in our descriptor.

As you may have noticed, we have three new keywords in this context.

  • module
  • exports
  • requires

These keywords are live in the context of the module, so you do not need to be aware of them in your application code.

If you have Java 9 > installed, you can list out all modules that are currently in the JDK by the *java –list-modules *keyword typed in your operating system console.

Another good function is that you can get a definition overview of every module independently with the *java –describe-module *keyword.

Summary

Hope you enjoyed my article. Here, I described the Java Platform Module System and what Java 9 brought to the language. This was the most major update to the JDK in the last 20 years.

In my upcoming articles, I would like to mention some other features of Java 9 and also introduce the most recent versions of the JDK —10, 11, and 12.

#java

What is GEEK

Buddha Community

The Java Platform Module System
Tyrique  Littel

Tyrique Littel

1600135200

How to Install OpenJDK 11 on CentOS 8

What is OpenJDK?

OpenJDk or Open Java Development Kit is a free, open-source framework of the Java Platform, Standard Edition (or Java SE). It contains the virtual machine, the Java Class Library, and the Java compiler. The difference between the Oracle OpenJDK and Oracle JDK is that OpenJDK is a source code reference point for the open-source model. Simultaneously, the Oracle JDK is a continuation or advanced model of the OpenJDK, which is not open source and requires a license to use.

In this article, we will be installing OpenJDK on Centos 8.

#tutorials #alternatives #centos #centos 8 #configuration #dnf #frameworks #java #java development kit #java ee #java environment variables #java framework #java jdk #java jre #java platform #java sdk #java se #jdk #jre #open java development kit #open source #openjdk #openjdk 11 #openjdk 8 #openjdk runtime environment

Samanta  Moore

Samanta Moore

1620458875

Going Beyond Java 8: Local Variable Type Inference (var) - DZone Java

According to some surveys, such as JetBrains’s great survey, Java 8 is currently the most used version of Java, despite being a 2014 release.

What you are reading is one in a series of articles titled ‘Going beyond Java 8,’ inspired by the contents of my book, Java for Aliens. These articles will guide you step-by-step through the most important features introduced to the language, starting from version 9. The aim is to make you aware of how important it is to move forward from Java 8, explaining the enormous advantages that the latest versions of the language offer.

In this article, we will talk about the most important new feature introduced with Java 10. Officially called local variable type inference, this feature is better known as the **introduction of the word **var. Despite the complicated name, it is actually quite a simple feature to use. However, some observations need to be made before we can see the impact that the introduction of the word var has on other pre-existing characteristics.

#java #java 11 #java 10 #java 12 #var #java 14 #java 13 #java 15 #verbosity

Samanta  Moore

Samanta Moore

1620462686

Spring Boot and Java 16 Records

In this article, we will discuss Java 16’s newest feature, Records. Then we will apply this knowledge and use it in conjunction with a Spring Boot application.

On March 16th, 2021, Java 16 was GA. With this new release, tons of new exciting features have been added. Check out the release notes to know more about these changes in detail. This article’s focus will be on Java Records, which got delivered with JEP 395. Records were first introduced in JDK 14 as a preview feature proposed by JEP 359, and with JDK 15, they remained in preview with JEP 384. However, with JDK 16, Records are no longer in preview.

I have picked Records because they are definitely the most favored feature added in Java 16, according to this Twitter poll by Java Champion Mala Gupta.

I also conducted a similar survey, but it was focused on features from Java 8 onwards. The results were not unexpected, as Java 8 is still widely used. Very unfortunate, though, as tons of new features and improvements are added to newer Java versions. But in terms of features, Java 8 was definitely a game-changer from a developer perspective.

So let’s discuss what the fuss is about Java Records.

#java #springboot #java programming #records #java tutorials #java programmer #java records #java 16

Ruth  Nabimanya

Ruth Nabimanya

1620633584

System Databases in SQL Server

Introduction

In SSMS, we many of may noticed System Databases under the Database Folder. But how many of us knows its purpose?. In this article lets discuss about the System Databases in SQL Server.

System Database

Fig. 1 System Databases

There are five system databases, these databases are created while installing SQL Server.

  • Master
  • Model
  • MSDB
  • Tempdb
  • Resource
Master
  • This database contains all the System level Information in SQL Server. The Information in form of Meta data.
  • Because of this master database, we are able to access the SQL Server (On premise SQL Server)
Model
  • This database is used as a template for new databases.
  • Whenever a new database is created, initially a copy of model database is what created as new database.
MSDB
  • This database is where a service called SQL Server Agent stores its data.
  • SQL server Agent is in charge of automation, which includes entities such as jobs, schedules, and alerts.
TempDB
  • The Tempdb is where SQL Server stores temporary data such as work tables, sort space, row versioning information and etc.
  • User can create their own version of temporary tables and those are stored in Tempdb.
  • But this database is destroyed and recreated every time when we restart the instance of SQL Server.
Resource
  • The resource database is a hidden, read only database that holds the definitions of all system objects.
  • When we query system object in a database, they appear to reside in the sys schema of the local database, but in actually their definitions reside in the resource db.

#sql server #master system database #model system database #msdb system database #sql server system databases #ssms #system database #system databases in sql server #tempdb system database

Seamus  Quitzon

Seamus Quitzon

1602637135

Learning by Doing: How to Learn Java Basics by Building Your Own Project

Java is not the hardest language to start with. So, it becomes way popular among novice developers joining the ranks of Java coders every single day. If you are reading this blog post, you might be interested in learning Java.

Java is widely used across industry, and especially in the area of Enterprise software, which results in many high paying job opportunities and makes this programming language a common language for newbies. A general promotion of it within colleges and other institutions providing a formal Computer Science education also contributes to its popularity.

However, these are not the only advantages of Java — among other things, it allows you to adopt good practices and makes it way easier to learn other languages in the future. And with no doubt, you can easily learn it if you’re following the right approach. In this post, I am going to share some of them with you.

The Importance of Practice in Programming

Beyond all doubt, practice is important and valuable. But, before we get to the advantages of hands-on experience, I want to draw your attention to one essential thing I often tell my students.

New programmers who are just learning and start implementing things, without being supervised, often end up adapting bad practices. To avoid that, especially when you are making your first steps in programming, I recommend looking for a person who will supervise you and teach you. A strong mentorship with someone engaged in a serious project, as well as communication within the community in the form of sharing code and asking for feedback, is worth the effort. Similarly, when you are applying for your first job, you want to be looking for a company with a strong team and a good leader who would be keen on investing into your learning.

Now, let’s return to practical experience. Learning by doing is different from learning by passively consuming the information. To make sure we can use all the newly acquired technology, we should put our skills to test and write tons of code. The benefits of hands-on experience are almost endless.

Efficiency and Productivity

By practicing, you get a clear understanding of what programming is. Consequently, you start doing better with each new hands-on task, complete it faster, and thus become more productive.

Even if you are not working on real-world projects yet, it’s important to get used to having deadlines. They are inextricably linked to the programming process. My recommendation is to set up your own deadlines while practicing stage and follow them as closely as possible.

#java #learn java #java code #learn java in easy way #learn java course #learn java development