{"id":15068949,"url":"https://github.com/goxr3plus/java9-modules-tutorial","last_synced_at":"2025-10-23T23:55:38.426Z","repository":{"id":89888326,"uuid":"190211082","full_name":"goxr3plus/java9-modules-tutorial","owner":"goxr3plus","description":":new: (  Simple Module , Optional  , Transitive ,  Cyclic , Qualified Exports  , Module Graph , Observable , Aggregator ,  Package Naming Conflicts ,  Module Resolution Process ) ","archived":false,"fork":false,"pushed_at":"2020-02-17T10:58:49.000Z","size":93,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-24T14:44:15.786Z","etag":null,"topics":["java11","java9-jigsaw","java9module"],"latest_commit_sha":null,"homepage":"https://www.udemy.com/java-9-new-features-in-simple-way-jshell-jpms-and-more/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/goxr3plus.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":"GOXR3PLUSTUDIO","open_collective":null,"ko_fi":"goxr3plusstudio","tidelift":null,"custom":"https://www.paypal.me/GOXR3PLUSCOMPANY"}},"created_at":"2019-06-04T13:49:48.000Z","updated_at":"2024-01-23T10:43:51.000Z","dependencies_parsed_at":"2023-06-16T00:45:33.675Z","dependency_job_id":null,"html_url":"https://github.com/goxr3plus/java9-modules-tutorial","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goxr3plus%2Fjava9-modules-tutorial","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goxr3plus%2Fjava9-modules-tutorial/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goxr3plus%2Fjava9-modules-tutorial/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/goxr3plus%2Fjava9-modules-tutorial/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/goxr3plus","download_url":"https://codeload.github.com/goxr3plus/java9-modules-tutorial/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248255954,"owners_count":21073426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java11","java9-jigsaw","java9module"],"created_at":"2024-09-25T01:39:49.154Z","updated_at":"2025-10-23T23:55:38.338Z","avatar_url":"https://github.com/goxr3plus.png","language":"Java","funding_links":["https://patreon.com/GOXR3PLUSTUDIO","https://ko-fi.com/goxr3plusstudio","https://www.paypal.me/GOXR3PLUSCOMPANY"],"categories":[],"sub_categories":[],"readme":"# Java 9 ++ modules full tutorial \n#### Everything is tested with JDK 11.0.3\n![Logging-Sins-793x397](https://user-images.githubusercontent.com/20374208/58885740-674c4900-86eb-11e9-9448-b0af3d8b52c0.png)\n### Complete PDF for the tutorial [download](https://github.com/goxr3plus/java9-modules-tutorial/files/3256292/JPMS.PDF)\n\nI tried to make a simple yet fun, including code examples and pictures tutorial about a **hot and important topic** which is JPMS([**Java Platform Module System**](https://en.wikipedia.org/wiki/Java_Platform_Module_System)) which came in Java 9.\n\n- **Tutorial Contents**\n  - [**Simple module**](#1)\n  - [**Optional**](#2)\n  - [**Transitive**](#3)\n  - [**Cyclic**](#4)\n  - [**Qualified Exports**](#5)\n  - [**Observable**](#6)\n  - [**Aggregator**](#7)\n  - [**Module Graph**](#8)\n  - [**Package Naming Conflicts**](#9)\n  - [**Module Resolution Process**](#10)\n  \n\nHighly based on  [ java-9-new-features-in-simple-way-jshell-jpms-and-more ](https://www.udemy.com/java-9-new-features-in-simple-way-jshell-jpms-and-more/) and [Jenkov Tutorials](http://tutorials.jenkov.com/java/modules.html)\n\n![chrome_2019-06-05_11-35-10](https://user-images.githubusercontent.com/20374208/58942200-fd34b200-8785-11e9-8f9c-dcb1aec1cf24.png)\n\n![chrome_2019-06-05_11-39-19](https://user-images.githubusercontent.com/20374208/58942502-906de780-8786-11e9-98e7-4d5f070053c5.png)\n\n---\n\n![chrome_2019-06-05_11-41-00](https://user-images.githubusercontent.com/20374208/58942638-cf9c3880-8786-11e9-8ddd-76c120c49d6f.png)\n\n\u003ca name=\"1\"\u003e\u003c/a\u003e\n---\n# 1. ------------------- Simple module -------------------\n\n![chrome_2019-06-05_11-43-36](https://user-images.githubusercontent.com/20374208/58942863-433e4580-8787-11e9-829d-cda9256aaef9.png)\n![chrome_2019-06-05_14-47-44](https://user-images.githubusercontent.com/20374208/58954143-f9faef80-87a0-11e9-8e8c-452c2511be3f.png)\n![chrome_2019-06-05_14-47-58](https://user-images.githubusercontent.com/20374208/58954144-f9faef80-87a0-11e9-8cfd-7376aa3816dd.png)\n\n##### Ps i have provided all the code in folders so you don't have to manually type it ;\n  Compile :\n  \n  ``` JAVA\n  javac --module-source-path simple_module -d out1 -m moduleA\n  ``` \n\n  Run :\n  \n  ``` JAVA\n  java --module-path out1 -m moduleA/pack1.Main\n  ```\n\u003ca name=\"2\"\u003e\u003c/a\u003e\n---\n# 2. ------------------- Optional -------------------\n\n![chrome_2019-06-05_13-44-20](https://user-images.githubusercontent.com/20374208/58950802-3e35c200-8798-11e9-816b-f8305c705c10.png)\n![chrome_2019-06-05_13-48-10](https://user-images.githubusercontent.com/20374208/58950963-a5ec0d00-8798-11e9-9b93-60847615f067.png)\n![chrome_2019-06-05_13-45-15](https://user-images.githubusercontent.com/20374208/58950805-3ece5880-8798-11e9-9659-456fcc98c259.png)\n![chrome_2019-06-05_13-45-28](https://user-images.githubusercontent.com/20374208/58950806-3ece5880-8798-11e9-985e-5bade3de14af.png)\n![chrome_2019-06-05_13-47-21](https://user-images.githubusercontent.com/20374208/58950962-a5ec0d00-8798-11e9-9eb6-8c578883156d.png)\n\n\n  Compile :\n  \n  ``` JAVA\n  javac --module-source-path optional_module -d out2 -m moduleA,moduleB\n  ```\n\n  Run :\n  \n  ``` JAVA\n  java --module-path out2 -m moduleB/pack2.Main\n  ```\n\u003ca name=\"3\"\u003e\u003c/a\u003e\n---\n# 3. ------------------- Transitive -------------------  \n\n![chrome_2019-06-05_13-36-59](https://user-images.githubusercontent.com/20374208/58950535-b780e500-8797-11e9-8af0-34e5bf10a33d.png)\n![chrome_2019-06-05_13-37-16](https://user-images.githubusercontent.com/20374208/58950537-b780e500-8797-11e9-9016-54cada9774b8.png)\n![chrome_2019-06-05_13-41-54](https://user-images.githubusercontent.com/20374208/58950538-b780e500-8797-11e9-900c-89eca1165b5a.png)\n \n **Be careful not spaces are allowed between (moduleA,moduleB,moduleC)**\n  \n  Compile :\n  \n ``` JAVA\n javac --module-source-path transitive_module -d out3 -m moduleA,moduleB,moduleC\n ```\n\n\n  Run :\n  \n ``` JAVA\n java --module-path out3 -m moduleC/pack3.Main\n ```\n\u003ca name=\"4\"\u003e\u003c/a\u003e\n---\n# 4. ------------------- Cyclic ------------------- \n\n\n![chrome_2019-06-05_11-32-23](https://user-images.githubusercontent.com/20374208/58942031-a038fc00-8785-11e9-802d-7349461d92fc.png)\n![chrome_2019-06-05_11-32-32](https://user-images.githubusercontent.com/20374208/58942032-a0d19280-8785-11e9-9c9c-c1ed6abdf6c1.png)\n![2019-06-05_13-52-25](https://user-images.githubusercontent.com/20374208/58951203-290d6300-8799-11e9-84b9-91ec28e6939f.png)\n\n  Compile :\n  \n``` JAVA\njavac  --module-source-path cyclic_module -d out4 -m moduleA,moduleB\n```\n\nThis will produce the following error :\n\n``` JAVA\nerror: cyclic dependence involving moduleA requires moduleA;\n```\n\n![chrome_2019-06-05_11-26-05](https://user-images.githubusercontent.com/20374208/58941549-b6928800-8784-11e9-856f-8914ac6f3779.png)\n\n\u003ca name=\"5\"\u003e\u003c/a\u003e\n---\n# 5. ------------------- Qualified Exports-------------------  \n\n![chrome_2019-06-05_13-53-55](https://user-images.githubusercontent.com/20374208/58951282-5eb24c00-8799-11e9-8805-96f8d9f2bcb1.png)\n![chrome_2019-06-05_14-47-44](https://user-images.githubusercontent.com/20374208/58954268-5c53f000-87a1-11e9-886e-2316b1390602.png)\n![chrome_2019-06-05_14-52-15](https://user-images.githubusercontent.com/20374208/58954318-85748080-87a1-11e9-9783-f5a824174da2.png)\n\n\n  Compile : \n  ``` JAVA \n  javac --module-source-path qualified_module -d out5 -m exporterModule,moduleA,moduleB\n  ```\n  \n  The error:\n  \n  ``` JAVA \n   error: package pack2 is not visible\n            import pack2.B;\n                   ^\n          (package pack2 is declared in module exporterModule, which does not export it to module moduleB)\n          1 error\n  ```\n  \n  How to solve :\n  Well as we can see that error happens because inside our **exporterModule** we allow access to **pack2** only for **moduleA** :\n  \n  ![chrome_2019-06-05_14-42-10](https://user-images.githubusercontent.com/20374208/58953810-29f5c300-87a0-11e9-8a89-ff9c796ebed4.png)\n\n\n  Do you want to fix it ? \n  \n  Simply **export pack2 for moduleB also** like this :\n\n\n  ``` JAVA\n  export pack2 to moduleA,moduleB;\n  \n  ```\n  \n  Okay but now how to run sir ?\n\n ``` JAVA\n  java --module-path out5 -m moduleA/pack1.Test\n ```\n  \n ``` JAVA\n  java --module-path out5 -m moduleB/pack1.Test\n ```\n \n \u003ca name=\"6\"\u003e\u003c/a\u003e\n---\n# 6. ------------------- Observable -------------------\n\n![chrome_2019-06-06_18-33-04](https://user-images.githubusercontent.com/20374208/59045888-8e408180-8889-11e9-8d03-d5ec84ae2e83.png)\n\n\n Compile :\n  \n ``` JAVA\n //TODO\n ```\n\n\n Run :\n  \n ``` JAVA\n  //TODO\n ```\n\n\n\u003ca name=\"7\"\u003e\u003c/a\u003e\n---\n# 7. ------------------- Aggregator -------------------  \n\n\n![chrome_2019-06-06_18-16-35](https://user-images.githubusercontent.com/20374208/59044922-c0e97a80-8887-11e9-8d0b-a1d23231b3f6.png)\n![chrome_2019-06-06_18-16-48](https://user-images.githubusercontent.com/20374208/59044927-c0e97a80-8887-11e9-9ede-ade53122ce5a.png)\n![chrome_2019-06-06_18-17-36](https://user-images.githubusercontent.com/20374208/59044928-c0e97a80-8887-11e9-8e97-390ad24e84e8.png)\n![chrome_2019-06-06_18-17-52](https://user-images.githubusercontent.com/20374208/59044929-c1821100-8887-11e9-849e-f08d8ef584a7.png)\n![chrome_2019-06-06_18-18-59](https://user-images.githubusercontent.com/20374208/59044930-c1821100-8887-11e9-90fa-4001217bdffe.png)\n![chrome_2019-06-06_18-19-16](https://user-images.githubusercontent.com/20374208/59044931-c1821100-8887-11e9-92a1-d29cf3301e3b.png)\n![chrome_2019-06-06_18-19-35](https://user-images.githubusercontent.com/20374208/59044933-c1821100-8887-11e9-94cd-a8fca4208ba4.png)\n\n Compile :\n  \n ``` JAVA\n  javac --module-source-path aggregator_module -d out7 -m aggregator,moduleA,moduleB,moduleC,useModule\n ```\n \n\n Run :\n  \n ``` JAVA\n  java --module-path out7 -m useModule/pack4.Main\n ```\n\n\n\u003ca name=\"8\"\u003e\u003c/a\u003e\n---\n# 8. ------------------- Module Graph -------------------  \n\n\n![chrome_2019-06-06_10-39-20](https://user-images.githubusercontent.com/20374208/59015559-f53d4680-8847-11e9-945f-8880116a45ce.png)\n![chrome_2019-06-06_10-48-39](https://user-images.githubusercontent.com/20374208/59015940-d4c1bc00-8848-11e9-9b26-d41013453b80.png)\n![2019-06-06_10-41-03](https://user-images.githubusercontent.com/20374208/59015561-f5d5dd00-8847-11e9-95ef-31ded987811f.png)\n![chrome_2019-06-06_10-41-31](https://user-images.githubusercontent.com/20374208/59015562-f5d5dd00-8847-11e9-9f05-85de1c2eb3be.png)\n![chrome_2019-06-06_10-41-51](https://user-images.githubusercontent.com/20374208/59015563-f5d5dd00-8847-11e9-8184-fc516f8e8dea.png)\n![chrome_2019-06-06_10-42-03](https://user-images.githubusercontent.com/20374208/59015564-f5d5dd00-8847-11e9-89c2-6b852219c4b1.png)\n![chrome_2019-06-06_10-42-12](https://user-images.githubusercontent.com/20374208/59015566-f66e7380-8847-11e9-86ab-d7e6799a866a.png)\n![chrome_2019-06-06_10-42-23](https://user-images.githubusercontent.com/20374208/59015567-f66e7380-8847-11e9-94c6-86080734321b.png)\n\n\u003ca name=\"9\"\u003e\u003c/a\u003e\n---\n# 9. ------------ Package Naming Conflicts ------------\n\n![chrome_2019-06-10_15-49-59](https://user-images.githubusercontent.com/20374208/59196550-af5de680-8b97-11e9-843c-59b4384d03aa.png)\n![chrome_2019-06-10_15-50-33](https://user-images.githubusercontent.com/20374208/59196552-af5de680-8b97-11e9-8635-ba5702194a6b.png)\n![chrome_2019-06-10_15-50-45](https://user-images.githubusercontent.com/20374208/59196553-af5de680-8b97-11e9-9496-023ec2b7b821.png)\n![chrome_2019-06-10_15-51-00](https://user-images.githubusercontent.com/20374208/59196554-aff67d00-8b97-11e9-81b9-2617b95b2389.png)\n\n Compile :\n  \n ``` JAVA\n  javac  --module-source-path name_conflicts_module -d out9 -m moduleA,moduleB,useModule\n ```\n \n This will produce the following error :\n\n``` JAVA\nerror: module useModule reads package pack1 from both moduleA and moduleB\nmodule useModule{\n^\n1 error\n```\n\n\u003ca name=\"10\"\u003e\u003c/a\u003e\n---\n# 10. ------------ Module Resolution Process ------------ \n\n![chrome_2019-06-10_16-06-02](https://user-images.githubusercontent.com/20374208/59197415-f64cdb80-8b99-11e9-8ed9-5ec4b7add576.png)\n![chrome_2019-06-10_16-06-35](https://user-images.githubusercontent.com/20374208/59197416-f64cdb80-8b99-11e9-98ac-38c11509130f.png)\n![chrome_2019-06-10_16-06-51](https://user-images.githubusercontent.com/20374208/59197418-f64cdb80-8b99-11e9-9668-8e8060923af4.png)\n![chrome_2019-06-10_16-07-02](https://user-images.githubusercontent.com/20374208/59197419-f64cdb80-8b99-11e9-90a3-b377c3f34cc8.png)\n![chrome_2019-06-10_16-07-38](https://user-images.githubusercontent.com/20374208/59197420-f64cdb80-8b99-11e9-8680-b230fac2b96c.png)\n![chrome_2019-06-10_16-07-46](https://user-images.githubusercontent.com/20374208/59197421-f6e57200-8b99-11e9-9ab7-f97a06f3b3c7.png)\n\n Compile :\n  \n ``` JAVA\n   javac --java-module-path resolution_process_module -d out10 -m useModule,moduleA,moduleB,moduleC,moduleD\n ```\n \n  Run :\n  \n ``` JAVA\n   java --module-path out10 --show-module-resolution -m useModule\n ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoxr3plus%2Fjava9-modules-tutorial","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoxr3plus%2Fjava9-modules-tutorial","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoxr3plus%2Fjava9-modules-tutorial/lists"}