<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Elder Moraes</title>
    <description>The latest articles on DEV Community by Elder Moraes (@elderjava).</description>
    <link>https://dev.to/elderjava</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F129982%2F761da13f-50c9-4921-8114-d52c0e8b42d9.png</url>
      <title>DEV Community: Elder Moraes</title>
      <link>https://dev.to/elderjava</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/elderjava"/>
    <language>en</language>
    <item>
      <title>Java Train #1 – JDK9 – Modularization</title>
      <dc:creator>Elder Moraes</dc:creator>
      <pubDate>Wed, 15 Jan 2020 17:03:01 +0000</pubDate>
      <link>https://dev.to/elderjava/java-train-1-jdk9-modularization-29e9</link>
      <guid>https://dev.to/elderjava/java-train-1-jdk9-modularization-29e9</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi1.wp.com%2Feldermoraes.com%2Fwp-content%2Fuploads%2F2019%2F11%2Ffabrizio-verrecchia-BXwbfuM0cdk-unsplash.jpg%3Fresize%3D300%252C255%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi1.wp.com%2Feldermoraes.com%2Fwp-content%2Fuploads%2F2019%2F11%2Ffabrizio-verrecchia-BXwbfuM0cdk-unsplash.jpg%3Fresize%3D300%252C255%26ssl%3D1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As announced &lt;a href="https://dev.to/elderjava/i-want-to-catch-the-java-train-5bh4"&gt;here&lt;/a&gt;, I’m now working on this series, where it will be covered the main features of each JDK release. So… let’s do this! This is the first leg of our journey.&lt;/p&gt;

&lt;h1&gt;
  
  
  JDK 9
&lt;/h1&gt;

&lt;p&gt;Some Java releases are special. I’m almost sure that you’ll agree that JDK 9 is one of them. And if I ask you “why”, you’ll probably give these answers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Module System, or Project Jigsaw&lt;/li&gt;
&lt;li&gt;It took 3.5 years to become available (from version 8)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And you are (mostly) right! But… that’s all? Almost 4 years for the modularity on Java?&lt;/p&gt;

&lt;p&gt;Of course not. This release is huge! There are exactly 91 features mentioned on the release page of the OpenJDK 9.&lt;/p&gt;

&lt;p&gt;So… let’s dig into this version. Of course, I won’t detail all these 91 features. My focus here is to help you improve your code, project, and career. So I’ll cover/mention the features that affect directly one of (or all) those three areas.&lt;/p&gt;

&lt;p&gt;At this post, I’ll cover the modularization of the Java Platform.&lt;/p&gt;

&lt;h1&gt;
  
  
  Project Jigsaw
&lt;/h1&gt;

&lt;p&gt;Ok, I can’t talk about JDK 9 without mention Project Jigsaw. But as it was so extensively explored out there, I’ll give you some specific highlights over it.&lt;/p&gt;

&lt;p&gt;Project Jigsaw is a set of many JEPs:&lt;/p&gt;

&lt;p&gt;200: The Modular JDK&lt;br&gt;
201: Modular Source Code&lt;br&gt;
220: Modular Run-Time Images&lt;br&gt;
253: Prepare JavaFX UI Controls &amp;amp; CSS APIs for Modularization&lt;br&gt;
261: Module System&lt;br&gt;
275: Modular Java Application Packaging&lt;br&gt;
And one thing that you notice just by looking at these JEPs is that the JDK itself is now modularized. It’s not just a matter of code/packaging organization. This is an important note, as it should drive you to change the way you think about the Java platform.&lt;/p&gt;

&lt;p&gt;The modularization system was specified under the JSR 376 and affected:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Java Language Specification&lt;/li&gt;
&lt;li&gt;Java Virtual Machine Specification&lt;/li&gt;
&lt;li&gt;API Specification&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So let’s check a simple example of how you can create your first module.&lt;/p&gt;
&lt;h1&gt;
  
  
  Coffee App
&lt;/h1&gt;

&lt;p&gt;The paths are &lt;em&gt;very&lt;/em&gt; important when working with modules. So, before we begin, create this structure:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi1.wp.com%2Feldermoraes.com%2Fwp-content%2Fuploads%2F2020%2F01%2Ftree.png%3Fw%3D330%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi1.wp.com%2Feldermoraes.com%2Fwp-content%2Fuploads%2F2020%2F01%2Ftree.png%3Fw%3D330%26ssl%3D1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It will save you a lot of time and prevent issues.&lt;/p&gt;

&lt;p&gt;Now let’s edit the src/coffee.module/coffe/module/Coffee.java file:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Then edit the src/coffee.module/module-info.java like this:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Now we code our Coffee Shop. Edit the src/coffee.shop/coffee/shop/CoffeeShop.java:&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;And finally the module-info.java for this module (under src/coffee.shop/module-info.java):&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;Now in the same level as the src folder, you create this folders structure:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi0.wp.com%2Feldermoraes.com%2Fwp-content%2Fuploads%2F2020%2F01%2Ftree-mods.png%3Fzoom%3D1.25%26resize%3D229%252C151%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi0.wp.com%2Feldermoraes.com%2Fwp-content%2Fuploads%2F2020%2F01%2Ftree-mods.png%3Fzoom%3D1.25%26resize%3D229%252C151%26ssl%3D1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Your final tree must be like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi1.wp.com%2Feldermoraes.com%2Fwp-content%2Fuploads%2F2020%2F01%2Ftree-full.png%3Fw%3D334%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fi1.wp.com%2Feldermoraes.com%2Fwp-content%2Fuploads%2F2020%2F01%2Ftree-full.png%3Fw%3D334%26ssl%3D1"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If it is not, go back and fix it! 😉&lt;/p&gt;

&lt;p&gt;Now you are ready to compile and run your Coffee App. Run the commands below in this exact order.&lt;/p&gt;

&lt;p&gt;First, we compile our Coffee module:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;javac -d mods/coffee.module src/coffee.module/module-info.java src/coffee.module/coffee/module/Coffee.java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we compile our CoffeShope module, paying attention to the reference made to the Coffe module:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;javac --module-path mods -d mods/coffee.shop src/coffee.shop/module-info.java src/coffee.shop/coffee/shop/CoffeeShop.java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The –module-path mods tell the compiler where to find the modules needed to compile this one.&lt;/p&gt;

&lt;p&gt;Now it’s time to order a coffee!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;java --module-path mods -m coffee.shop/coffee.shop.CoffeeShop
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you got a message “Enjoy your [CoffeeType]”, then your module is working successfully!&lt;/p&gt;

&lt;p&gt;You can check the full source code of this example here: &lt;a href="https://github.com/eldermoraes/javatrain/tree/master/01" rel="noopener noreferrer"&gt;https://github.com/eldermoraes/javatrain/tree/master/01&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Don’t forget to left your questions and/other comments that you might have. See you next time!&lt;/p&gt;

</description>
      <category>java</category>
      <category>release</category>
      <category>blog</category>
      <category>javatrain</category>
    </item>
    <item>
      <title>I want to catch the Java train</title>
      <dc:creator>Elder Moraes</dc:creator>
      <pubDate>Wed, 15 Jan 2020 16:19:04 +0000</pubDate>
      <link>https://dev.to/elderjava/i-want-to-catch-the-java-train-5bh4</link>
      <guid>https://dev.to/elderjava/i-want-to-catch-the-java-train-5bh4</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V3xLGbh3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i1.wp.com/eldermoraes.com/wp-content/uploads/2019/11/fabrizio-verrecchia-BXwbfuM0cdk-unsplash.jpg%3Fresize%3D300%252C255%26ssl%3D1" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V3xLGbh3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i1.wp.com/eldermoraes.com/wp-content/uploads/2019/11/fabrizio-verrecchia-BXwbfuM0cdk-unsplash.jpg%3Fresize%3D300%252C255%26ssl%3D1" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What? Does Java have a new release every 6 months? My project can’t follow this… My company won’t even want that!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I’ve already got to deal with delayed projects, bugs to be fixed, angry customers on the phone… How am I supposed to keep up with 6 months' versions?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Being up to date with Java versions can be huge for you and your projects. Performance improvements, to be more productive writing code… not to mention making sure you have a secure environment!&lt;/p&gt;

&lt;p&gt;Being up-to-date is also great for your career as a developer. And there is an easier way to do that! You don’t need to do it all at once, and you don’t need to do it alone.&lt;/p&gt;

&lt;p&gt;I’m starting a series of content that will help you along the way. Together, we can work on each feature. Join me on this journey and let’s catch the Java release train together!&lt;/p&gt;

</description>
      <category>java</category>
      <category>releases</category>
      <category>blog</category>
      <category>javatrain</category>
    </item>
  </channel>
</rss>
