{"id":603,"date":"2020-08-05T08:13:20","date_gmt":"2020-08-05T08:13:20","guid":{"rendered":"https:\/\/www.javaindia.in\/blog\/?p=603"},"modified":"2020-08-05T08:13:20","modified_gmt":"2020-08-05T08:13:20","slug":"role-of-jpms-in-the-java-web-application-development","status":"publish","type":"post","link":"https:\/\/www.javaindia.in\/blog\/role-of-jpms-in-the-java-web-application-development\/","title":{"rendered":"What is the role of JPMS in the Java Web Application Development?"},"content":{"rendered":"<p style=\"text-align: justify;\"><span style=\"color: #000000;\">JPMS has brought a complete change to the Java libraries, language, and runtime. This overall means that it affects the complete stack that developers code on a regular basis and with JPMS could have a big impact. The key concept to know here is that JPMS adds a new concept to the JVM modules. Earlier the code was managed into fields, methods, classes, interfaces and packages. But with Java SE 9 there is a new concept named modules.<br \/>\n<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 Class is a container of fields and methods<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 Package is a container of classes and interfaces<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 Module is a container of packages<\/span><br \/>\n<span style=\"color: #000000;\"><br \/>\nSince it is a new JVM element, the runtime can implement strong access control. With Java 8, a major challenge for <a href=\"https:\/\/www.javaindia.in\/\" target=\"_blank\" rel=\"noopener\">Java Development Company <\/a>was a class that cannot be seen by other classes when declared private. With Java 9, a developer can hide a package within a module.<\/span><br \/>\n<span style=\"color: #000000;\"><br \/>\n<strong>What is a Module?<\/strong><\/span><br \/>\n<span style=\"color: #000000;\">Modularity offers a higher level of aggregation. This new language element has a unique name, reusable group of related packages, resources like images, and XML files. A module descriptor specifies the following:<br \/>\n<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 name<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 dependencies (that is, other modules this module depends on)<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 packages it explicitly makes available to other modules<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 services it offers<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 services it consumes<\/span><br \/>\n<span style=\"color: #000000;\"><br \/>\n<strong>Why Java needs modules?<\/strong><\/span><br \/>\n<span style=\"color: #000000;\">JPMS is the result of the project Jigsaw, which was started with the following objectives:<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 Make it simpler for the developers to manage large apps and libraries<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 Enhance the structure and security of the platform<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 Improve overall app performance<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 Handle breakdown of the platform for smaller gadgets<\/span><br \/>\n<span style=\"color: #000000;\"><br \/>\nIt\u2019s important to note here that the JPMS is a SE feature, and affects every aspect of <a href=\"https:\/\/www.javaindia.in\/services\/java-enterprise-application-development\" target=\"_blank\" rel=\"noopener\">Enterprise application in Java<\/a> from the starting stage. The change is properly designed to ensure most code to perform without modification when switching from Java 8 to Java 9.<\/span><br \/>\n<span style=\"color: #000000;\"><br \/>\n<strong>How to Build a Modular Java Project?<\/strong><\/span><br \/>\n<span style=\"color: #000000;\">To build a module following listings mentioned below are need to be added:<\/span><br \/>\n<span style=\"color: #000000;\"><br \/>\n<strong>Listing 1: com.javaworld.mod1\/module-info.java<\/strong><\/span><\/p>\n<pre class=\"le lf lg lh li hk fj ci\"><span style=\"color: #000000;\"><span class=\"nu mx dx aq ns b ea nv nw l nx\" data-selectable-paragraph=\"\">module com.javaworld.mod1 {\r\n  exports com.javaworld.package1;\r\n}<\/span><\/span><\/pre>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">Here the module and the package it exports have different names. We are defining a module that simply exports a package.<\/span><br \/>\n<span style=\"color: #000000;\"><br \/>\n<strong>Listing 2: Name.java<\/strong><\/span><\/p>\n<pre class=\"le lf lg lh li hk fj ci\"><span style=\"color: #000000;\"><span class=\"nu mx dx aq ns b ea nv nw l nx\" data-selectable-paragraph=\"\">package com.javaworld.package1;\r\npublic class Name {\r\n public String getIt() {\r\n  return \"Java World\";\r\n }\r\n}<\/span><\/span><\/pre>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">It will become a class, package, and module upon which development of web application depend.<\/span><br \/>\n<span style=\"color: #000000;\"><br \/>\n<strong>Listing 3: com.javaworld.mod2\/module-info.java<\/strong><\/span><\/p>\n<pre class=\"le lf lg lh li hk fj ci\"><span style=\"color: #000000;\"><span class=\"nu mx dx aq ns b ea nv nw l nx\" data-selectable-paragraph=\"\">module com.javaworld.mod2 {\r\n requires com.javaworld.mod1;\r\n}<\/span><\/span><\/pre>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">This listing is pretty self-explanatory. It defines com.javaworld.mod2 module and requires com.javaworld.mod1.<\/span><br \/>\n<span style=\"color: #000000;\"><br \/>\n<strong>Listing 4: Hello.java<\/strong><\/span><\/p>\n<pre class=\"le lf lg lh li hk fj ci\"><span style=\"color: #000000;\"><span class=\"nu mx dx aq ns b ea nv nw l nx\" data-selectable-paragraph=\"\">package com.javaworld.package2;\r\nimport com.javaworld.package1.Name;\r\npublic class Hello {\r\n public static void main(String[] args) {\r\n  Name name = new Name();\r\n  System.out.println(\"Hello \" + name.getIt());\r\n }\r\n}<\/span><\/span><\/pre>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">Here, we start by defining the package, then importing the com.javawolrd.package1.Name class. Remember that these elements function the way they always do. The modules have changed how the packages are made available at the file structure level, not the code level.<\/span><br \/>\n<span style=\"color: #000000;\"><br \/>\n<strong>Frequently Asked Questions<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-390\" src=\"https:\/\/www.javaindia.in\/blog\/wp-content\/uploads\/2020\/02\/Frequently-asked-questions.jpg\" alt=\"frequently asked questions\" width=\"700\" height=\"350\" srcset=\"https:\/\/www.javaindia.in\/blog\/wp-content\/uploads\/2020\/02\/Frequently-asked-questions.jpg 700w, https:\/\/www.javaindia.in\/blog\/wp-content\/uploads\/2020\/02\/Frequently-asked-questions-300x150.jpg 300w, https:\/\/www.javaindia.in\/blog\/wp-content\/uploads\/2020\/02\/Frequently-asked-questions-360x180.jpg 360w\" sizes=\"auto, (max-width: 700px) 100vw, 700px\" \/><br \/>\n<\/strong><\/span><span style=\"color: #000000;\"><br \/>\n<strong>1. What is the use of a module in Java?<\/strong><\/span><br \/>\n<span style=\"color: #000000;\">A Java Module is a mechanism to package up your Java application and Java packages into Java modules. A Java module can specify which of the Java packages it contains that should be visible to other Java modules using this module. A Java module must also specify which other Java module is required to do its job.<\/span><br \/>\n<span style=\"color: #000000;\"><br \/>\n<strong>2. How do I use Java 9 modules?<\/strong><\/span><br \/>\n<span style=\"color: #000000;\">Java 9 Module \u2013 Create and use modules in Eclipse IDE<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 Creating a Java Project. We are creating a java project in Eclipse IDE.<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 Create a module-info.<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 Create a package and a class.<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 Export the package that we have created.<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 Let&#8217;s create another module.<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 Let&#8217;s create a class in the second module.<\/span><br \/>\n<span style=\"color: #000000;\">\u2022 Final Step.<\/span><br \/>\n<span style=\"color: #000000;\"><br \/>\n<strong>3. How do modules work?<\/strong><\/span><br \/>\n<span style=\"color: #000000;\">Modules are used to organize content in an organized manner. Modules essentially create a one-directional linear flow of what application should do. Each module can contain files, packages in an engaged manner.<\/span><br \/>\n<span style=\"color: #000000;\"><br \/>\n<strong>4. What is abstraction in Java?<br \/>\n<\/strong><\/span><span style=\"color: #000000;\">Data abstraction is the process of hiding certain details and showing only essential information to the user. Abstraction can be achieved with either abstract classes or interfaces.<\/span><br \/>\n<span style=\"color: #000000;\"><br \/>\n<strong>5. What is the use of Eclipse IDE?<\/strong><\/span><br \/>\n<span style=\"color: #000000;\">In the context of computing, Eclipse is an integrated development environment (IDE) for developing applications using the Java programming language and other programming languages such as C\/C++, Python, PERL, Ruby etc.<\/span><br \/>\n<span style=\"color: #000000;\"><br \/>\n<strong>Wrapping Up:<\/strong><\/span><br \/>\n<span style=\"color: #000000;\">JPMS is a remarkable sweeping change and it will take time to implement. You don\u2019t have to rush, since old versions of Java have a long-term support release. But, in the long run, older projects will need to <a href=\"https:\/\/www.javaindia.in\/hire-java-developer\" target=\"_blank\" rel=\"noopener\">hire Java developers<\/a> to migrate, and new ones will require using modules intelligently, hopefully capitalizing on some of the major benefits. Make sure you avail expertise from a reputed development agency having years of expertise in the Java web application development. This requires investment but will bring remarkable results for your business.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>JPMS has brought a complete change to the Java libraries, language, and runtime. This overall means that it affects the complete stack that developers code on a regular basis and with JPMS could have a big impact. The key concept to know here is that JPMS adds a new concept to the JVM modules. Earlier the code was managed into [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":605,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[50],"tags":[51],"class_list":["post-603","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jpms","tag-jpms"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/posts\/603","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/comments?post=603"}],"version-history":[{"count":6,"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/posts\/603\/revisions"}],"predecessor-version":[{"id":610,"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/posts\/603\/revisions\/610"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/media\/605"}],"wp:attachment":[{"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/media?parent=603"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/categories?post=603"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javaindia.in\/blog\/wp-json\/wp\/v2\/tags?post=603"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}