{"id":7962,"date":"2018-04-24T10:09:36","date_gmt":"2018-04-24T10:09:36","guid":{"rendered":"https:\/\/weblizar.com\/blog\/?p=7962"},"modified":"2025-08-11T12:14:44","modified_gmt":"2025-08-11T06:44:44","slug":"java-all-you-need-know-about-the-features-new-java","status":"publish","type":"post","link":"https:\/\/weblizar.com\/blog\/java-all-you-need-know-about-the-features-new-java\/","title":{"rendered":"Java 9 &#8211; All You Need To Know About The Features Of New Java"},"content":{"rendered":"<p>Java, the highly accessible programming language has been a no-brainer for developers across the globe. Ever since it\u2019s inception in 1995, the language has seen wide usage across various industries.<\/p>\n<p>Today, you will find Java on your phones. Powering Android OS and the myriad range of apps that Android offers. It is used for developing games like Minecraft which has a huge player-base. It also finds use in business applications like reading credit card information at shop tills and feeding the information between the systems and the banks.<\/p>\n<p>After a gap of 3 years, Java rolled out its new edition \u2013 Java SE 9. With several key architectural changes and add-on features, Java SE 9 offers a powerful solution that developers had been yearning for.<\/p>\n<p>Java 7 added try-with-resource in 2011, offering better resource management functionality.<br \/>\nJava 8 added lambda expressions, a good move but slightly flawed under OOP paradigm.<\/p>\n<p>Now <a href=\"https:\/\/mettl.com\/test\/java-assessment-tests\/\"><strong>Java Solutions<\/strong><\/a> allows programmers to have private methods. Private static methods! YES, you read that right!<\/p>\n<p>Java SE 8 offered many structural changes that were received with mixed emotions by developers. Majorly, these are the shortcomings of Java SE 8 that Java SE 9 has tried to overcome:<\/p>\n<ol>\n<li>The JDK was not navigable for the small computing device<\/li>\n<li>There was no overall improvement in application performance<\/li>\n<li>There was no overall security and maintenance of JDK<\/li>\n<li>Java developers faced difficulty to build and uphold the code libraries and larger application<\/li>\n<\/ol>\n<p>So, let\u2019s look at the key changes and enhancements that Java 9 offers over its predecessors<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Process API updates in Java 9<\/strong><\/p>\n<p>Traditionally, Java\u2019s API has been primitive in nature. That support to launch new processes, redirect output and error streams. In Java 9, the new updates to the Process API enable:<\/p>\n<ol>\n<li>Getting the PID of the current and any other JVM process<\/li>\n<li>Managing subprocesses<\/li>\n<li>Managing subprocesses<\/li>\n<li>Get information such as PID, name, and resource usage of the processes running in the system.<\/li>\n<\/ol>\n<p>This is a sample code, which prints the current PID as well as the current process information:<\/p>\n<p><code>public class NewFeatures<br \/>\n{<br \/>\npublic static void main(String [] args)<br \/>\n{<br \/>\nProcessHandle currentProcess = ProcessHandle.current();<br \/>\nSystem.out.println(\"PID:\"+ currentProcess.getPid());<br \/>\nProcessHandle.Info currentProcessInfo = currentProcess.info();<br \/>\nSystem.out.println(\"Info:\" + currentProcessInfo);<br \/>\n}<br \/>\n}<br \/>\n<\/code><\/p>\n<p><strong>HTTP\/2 client in Java 9<\/strong><\/p>\n<p>This feature is expected to be reformed in the subsequent releases or may even be removed completely.<br \/>\nPreviously developers would rely on the third-party libraries, for examles Apache HTTP, Jersey, and so many. The Java\u2019s HTTP API predates the HTTP\/1.1 specification and is synchronous and hard to maintain. These limitations called for the need to add a new API. The new HTTP client API provides the following:<\/p>\n<ol>\n<li>A simple and concise API to deal with most HTTP requests<\/li>\n<li>Support for HTTP\/2 specification<\/li>\n<li>Better performance<\/li>\n<li>Better security<\/li>\n<li>A few more enhancements<\/li>\n<\/ol>\n<p>Here is a code snippet to make an HTTP GET request using the new APIs. This is the module as defined in the file module-info.java:<\/p>\n<p><code>module newfeatures{<br \/>\nrequires jdk.incubator.httpclient;<br \/>\n}<br \/>\n<\/code><br \/>\nThe following code uses HTTP Client API. This is a part of <em>jdk.incubator.httpclient<\/em> module:<\/p>\n<p><code>import jdk.incubator.http.*;<br \/>\nimport java.net.URI;<br \/>\npublic class Http2Feature{<br \/>\npublic static void main(String[] args) throws Exception{<br \/>\nHttpClient client = HttpClient.newBuilder().build();<br \/>\nHttpRequest request = HttpRequest<br \/>\n.newBuilder(new URI(http:\/\/httpbin.org\/get;))<br \/>\n.GET()<br \/>\n.version(HttpClient.Version.HTTP_1_1)<br \/>\n.build();<br \/>\nHttpResponse.String response = client.send(request,<br \/>\nHttpResponse.BodyHandler.asString());<br \/>\nSystem.out.println(\"Status code:\" + response.statusCode());<br \/>\nSystem.out.println(\"Response Body:\" + response.body());<br \/>\n}<br \/>\n}<br \/>\n}<br \/>\n<\/code><br \/>\n<strong>More Concurrency Updates feature in Java 9<\/strong><\/p>\n<p>With Java 9, a new class called &#8211; java.util.concurrent.Flow has been introduced, which supports the implementation of a publish-subscribe framework. This framework enables developers to build components. These components can asynchronously consume a live stream of data by setting up publishers that produce the data and subscribers that consume the data. These are the new interfaces:<\/p>\n<ul>\n<li>java.util.concurrent.Flow.Publisher<\/li>\n<li>java.util.concurrent.Flow.Subscriber<\/li>\n<li>java.util.concurrent.Flow.Subscription<\/li>\n<li>java.util.concurrent.Flow.Processor (which acts as both Publisher and Subscriber).<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p><strong>Java Shell Scripting (Read-Eval-Print-Loop) in Java 9<\/strong><\/p>\n<p>The goal of Project Kulla was to investigate the addition of the REPL (Read-Eval-Print-Loop) tool for Java 9. This release of Java features a special command line tool called JShell. The goal here is to popularize and maximize usage of REPL. So, what does that mean? Now, you do not need to wrap a few lines of code in a separate method to run them. Efficient? I say YES.<br \/>\nFor instance, in Scala, a simple Hello World program is written as scala&gt;println(\u201cHello World\u201d);<br \/>\nLet\u2019s run the JShell command, as shown in the following image:<\/p>\n<p><a href=\"https:\/\/weblizar.com\/blog\/wp-content\/uploads\/2018\/05\/xzcxc-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-8001\" src=\"https:\/\/weblizar.com\/blog\/wp-content\/uploads\/2018\/05\/xzcxc-1.png\" alt=\"programming language, java 9\" width=\"378\" height=\"182\" srcset=\"https:\/\/weblizar.com\/blog\/wp-content\/uploads\/2018\/05\/xzcxc-1.png 378w, https:\/\/weblizar.com\/blog\/wp-content\/uploads\/2018\/05\/xzcxc-1-300x144.png 300w\" sizes=\"auto, (max-width: 378px) 100vw, 378px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Project Jigsaw in Java 9<\/strong><\/p>\n<p>The trump card of the new features in Java 9 is the aall-newmodule system. Creating complex systems often involves high level, complex codes which result in ambiguity. With code complexity, two fundamental problems are faced: Encapsulation of the code is difficult, and there is no notion of explicit dependencies between different JAR files of a system. Every public class can be accessed by any other public class on the classpath. This leads to unnecessary usage of classes that weren&#8217;t meant to be public API. Furthermore, the classpath itself is problematic: How do you know whether all the required JARs are there, and what about duplicate entries? The module system resolves both issues.<br \/>\nThis is where the robust nature of Java 9 is seen. Modular JAR files contain an additional module descriptor. In this module descriptor, `requires` statements are used to express dependencies on other modules. Additionally, `exports` statements control which packages are accessible to different modules. By default, all non-exported packages are encapsulated in the module.<\/p>\n<p>There are various JEPs, which are part of this project, as follows:<\/p>\n<p><a href=\"https:\/\/openjdk.org\/jeps\/200\" target=\"_blank\" rel=\"noopener noreferrer\">JEP 200<\/a> \u2013 modular JDK: This applies the Java platform module system to modularize the JDK that can be combined at compile time, build time, or runtime.<br \/>\n<a href=\"https:\/\/openjdk.org\/jeps\/201\" target=\"_blank\" rel=\"noopener noreferrer\">JEP 201<\/a> \u2013 modular source code: used to create modules and allows building tools to compile the created modules<br \/>\n<a href=\"https:\/\/openjdk.org\/jeps\/220\" target=\"_blank\" rel=\"noopener noreferrer\">JEP 220<\/a> \u2013 modular runtime images: This JEP improves performance, security, and maintainability by restructuring the JDK and JRE runtime images to accommodate modules<br \/>\n<a href=\"https:\/\/openjdk.org\/jeps\/282\" target=\"_blank\" rel=\"noopener noreferrer\">JEP 282<\/a> \u2013\u00a0The jlink, known as Java linker: usages as packaging modules &amp; their dependencies into fewer run times.<\/p>\n<p>&nbsp;<\/p>\n<p><strong>Multi-release JAR files<\/strong><\/p>\n<p>To leverage the new features of the Java platform on newer versions, the library developers must release a newer version of their library. Soon, there will be multiple versions of the library being maintained by the developers, which can be catastrophic. To overcome this limitation, Java 9 features multi-release of JAR files allowing developers to build JAR files with different versions of class files for different Java versions. Take a look at this example.<\/p>\n<p>An illustration of the current JAR files as follows:<\/p>\n<p>jar root<br \/>\n&#8211; A.class<br \/>\n&#8211; B.class<br \/>\n&#8211; C.class<\/p>\n<p>Here are how multi-release JAR files look like:<\/p>\n<p>jar root<\/p>\n<p>&#8211; A.class<br \/>\n&#8211; B.class<br \/>\n&#8211; C.class<br \/>\n&#8211; META-INF<br \/>\n&#8211; versions<br \/>\n&#8211; &#8211; 9<br \/>\n&#8211; &#8211; &#8211; &#8211; A.class<br \/>\n&#8211; &#8211; 10<br \/>\n&#8211; &#8211; &#8211; &#8211; B.class<\/p>\n<p>In the previous illustration, the JAR files supported class files for two Java versions 9 and 10.\u00a0So, when the JAR is executed on Java&#8217;s version 9, the A.class under the versions \u2013 9 folders are picked up for execution.<\/p>\n<p>The earlier versions of Java that doesn\u2019t support multi-release JAR files, the classes under the versions directory are never used. So, if you run the multi-release JAR file on Java 8, it\u2019s as good as running a simple JAR file.<\/p>\n<p>In my opinion, things are starting to change with Java. And this is a growing trend. Does it mean that popularity of Java and it&#8217;s used will be affected? Not at all. Java has been and still is an incredibly powerful and robust programming language in the tech industry today. Start learning Java and watch it make a difference in your career. Good luck!<\/p>\n<p>Author\u2019s note:<br \/>\nThat tech article is contributed by Sumit which works on trending technologies such as DevOps, Big Data, and Python. And in Digital Marketing team at Edureka.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java, the highly accessible programming language has been a no-brainer for developers across the globe. Ever since it\u2019s inception in 1995, the language has seen wide usage across various industries. Today, you will find Java on your phones. Powering Android OS and the myriad range of apps that Android offers. It is used for developing<\/p>\n","protected":false},"author":1,"featured_media":8034,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[176,706,172],"tags":[707,1430],"class_list":["post-7962","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-digital-updates","category-java","category-technical-content-writing","tag-java","tag-java-9"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Java 9 - All You Need To Know About The Features Of New Java - Weblizar Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/weblizar.com\/blog\/java-all-you-need-know-about-the-features-new-java\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Java 9 - All You Need To Know About The Features Of New Java - Weblizar Blog\" \/>\n<meta property=\"og:description\" content=\"Java, the highly accessible programming language has been a no-brainer for developers across the globe. Ever since it\u2019s inception in 1995, the language has seen wide usage across various industries. Today, you will find Java on your phones. Powering Android OS and the myriad range of apps that Android offers. It is used for developing\" \/>\n<meta property=\"og:url\" content=\"https:\/\/weblizar.com\/blog\/java-all-you-need-know-about-the-features-new-java\/\" \/>\n<meta property=\"og:site_name\" content=\"Weblizar Blog\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/www.facebook.com\/weblizarwp\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-24T10:09:36+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-08-11T06:44:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i0.wp.com\/weblizar.com\/blog\/wp-content\/uploads\/2018\/04\/Java-9-All-You-Need-To-Know-About-The-Features-Of-New-Java.jpg?fit=900%2C563&ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"900\" \/>\n\t<meta property=\"og:image:height\" content=\"563\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"weblizar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@weblizar\" \/>\n<meta name=\"twitter:site\" content=\"@weblizar\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"weblizar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Java 9 - All You Need To Know About The Features Of New Java - Weblizar Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/weblizar.com\/blog\/java-all-you-need-know-about-the-features-new-java\/","og_locale":"en_US","og_type":"article","og_title":"Java 9 - All You Need To Know About The Features Of New Java - Weblizar Blog","og_description":"Java, the highly accessible programming language has been a no-brainer for developers across the globe. Ever since it\u2019s inception in 1995, the language has seen wide usage across various industries. Today, you will find Java on your phones. Powering Android OS and the myriad range of apps that Android offers. It is used for developing","og_url":"https:\/\/weblizar.com\/blog\/java-all-you-need-know-about-the-features-new-java\/","og_site_name":"Weblizar Blog","article_publisher":"http:\/\/www.facebook.com\/weblizarwp","article_published_time":"2018-04-24T10:09:36+00:00","article_modified_time":"2025-08-11T06:44:44+00:00","og_image":[{"width":900,"height":563,"url":"https:\/\/i0.wp.com\/weblizar.com\/blog\/wp-content\/uploads\/2018\/04\/Java-9-All-You-Need-To-Know-About-The-Features-Of-New-Java.jpg?fit=900%2C563&ssl=1","type":"image\/jpeg"}],"author":"weblizar","twitter_card":"summary_large_image","twitter_creator":"@weblizar","twitter_site":"@weblizar","twitter_misc":{"Written by":"weblizar","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/weblizar.com\/blog\/java-all-you-need-know-about-the-features-new-java\/#article","isPartOf":{"@id":"https:\/\/weblizar.com\/blog\/java-all-you-need-know-about-the-features-new-java\/"},"author":{"name":"weblizar","@id":"https:\/\/weblizar.com\/blog\/#\/schema\/person\/8bd0de51e6e797ea0402f3ffa858a413"},"headline":"Java 9 &#8211; All You Need To Know About The Features Of New Java","datePublished":"2018-04-24T10:09:36+00:00","dateModified":"2025-08-11T06:44:44+00:00","mainEntityOfPage":{"@id":"https:\/\/weblizar.com\/blog\/java-all-you-need-know-about-the-features-new-java\/"},"wordCount":1247,"commentCount":1,"image":{"@id":"https:\/\/weblizar.com\/blog\/java-all-you-need-know-about-the-features-new-java\/#primaryimage"},"thumbnailUrl":"https:\/\/weblizar.com\/blog\/wp-content\/uploads\/2018\/04\/Java-9-All-You-Need-To-Know-About-The-Features-Of-New-Java.jpg","keywords":["Java","java 9"],"articleSection":["Digital Updates","Java","Technical Content Writing"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/weblizar.com\/blog\/java-all-you-need-know-about-the-features-new-java\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/weblizar.com\/blog\/java-all-you-need-know-about-the-features-new-java\/","url":"https:\/\/weblizar.com\/blog\/java-all-you-need-know-about-the-features-new-java\/","name":"Java 9 - All You Need To Know About The Features Of New Java - Weblizar Blog","isPartOf":{"@id":"https:\/\/weblizar.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/weblizar.com\/blog\/java-all-you-need-know-about-the-features-new-java\/#primaryimage"},"image":{"@id":"https:\/\/weblizar.com\/blog\/java-all-you-need-know-about-the-features-new-java\/#primaryimage"},"thumbnailUrl":"https:\/\/weblizar.com\/blog\/wp-content\/uploads\/2018\/04\/Java-9-All-You-Need-To-Know-About-The-Features-Of-New-Java.jpg","datePublished":"2018-04-24T10:09:36+00:00","dateModified":"2025-08-11T06:44:44+00:00","author":{"@id":"https:\/\/weblizar.com\/blog\/#\/schema\/person\/8bd0de51e6e797ea0402f3ffa858a413"},"breadcrumb":{"@id":"https:\/\/weblizar.com\/blog\/java-all-you-need-know-about-the-features-new-java\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/weblizar.com\/blog\/java-all-you-need-know-about-the-features-new-java\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/weblizar.com\/blog\/java-all-you-need-know-about-the-features-new-java\/#primaryimage","url":"https:\/\/weblizar.com\/blog\/wp-content\/uploads\/2018\/04\/Java-9-All-You-Need-To-Know-About-The-Features-Of-New-Java.jpg","contentUrl":"https:\/\/weblizar.com\/blog\/wp-content\/uploads\/2018\/04\/Java-9-All-You-Need-To-Know-About-The-Features-Of-New-Java.jpg","width":900,"height":563},{"@type":"BreadcrumbList","@id":"https:\/\/weblizar.com\/blog\/java-all-you-need-know-about-the-features-new-java\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/weblizar.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Java 9 &#8211; All You Need To Know About The Features Of New Java"}]},{"@type":"WebSite","@id":"https:\/\/weblizar.com\/blog\/#website","url":"https:\/\/weblizar.com\/blog\/","name":"Weblizar Blog","description":"Update yourself with all the latest tech news revolving around wordpress all at one place","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/weblizar.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/weblizar.com\/blog\/#\/schema\/person\/8bd0de51e6e797ea0402f3ffa858a413","name":"weblizar","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/83d3ba133e1fd5422595fc5deff6340a4c654d5372f5805eca8c25450ecdef1b?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/83d3ba133e1fd5422595fc5deff6340a4c654d5372f5805eca8c25450ecdef1b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/83d3ba133e1fd5422595fc5deff6340a4c654d5372f5805eca8c25450ecdef1b?s=96&d=mm&r=g","caption":"weblizar"}}]}},"_links":{"self":[{"href":"https:\/\/weblizar.com\/blog\/wp-json\/wp\/v2\/posts\/7962","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/weblizar.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/weblizar.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/weblizar.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/weblizar.com\/blog\/wp-json\/wp\/v2\/comments?post=7962"}],"version-history":[{"count":0,"href":"https:\/\/weblizar.com\/blog\/wp-json\/wp\/v2\/posts\/7962\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/weblizar.com\/blog\/wp-json\/wp\/v2\/media\/8034"}],"wp:attachment":[{"href":"https:\/\/weblizar.com\/blog\/wp-json\/wp\/v2\/media?parent=7962"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/weblizar.com\/blog\/wp-json\/wp\/v2\/categories?post=7962"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/weblizar.com\/blog\/wp-json\/wp\/v2\/tags?post=7962"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}