On 02/03/2018 09:22, Bernard Amade wrote:
Hello all
since my job is to write java tutorials I have to confess I am lost on some 
topics about the module system.
Here is a first concern:
- I used to teach to deploy resources in an additional jar at deploy time
- so if a code requesting a resource was in package/directory com.mycomp.biz then the 
resource was in a com.mycomp.biz.config directory ... in a different jar which could be 
written by the "deployment programmer".

with the module system I do not know how to have something similar.
Well may be the resource could be in a non-modular jar in the class-path (or 
added by patch-module)
but realy I don't know what could be the best option (put it in a modular jar? but then 
how to write the module-info, how to update the module-info of other modules - something 
done by the deployment programmer- ? how to start the jar: from the command line? but 
then can we still have a "clickable" jar?

Resources aren't a first class concept in the module system so we of course recommend using services itself.

If you are migrating existing code without doing any significant rearchitecture then modules can open packages to allow resources be located by code in other modules with the legacy ClassLoader.getResourceXXX APIs. There is also support in the ResourceBundle API to use resource bundles in other modules.

The Quick Start Guide is indeed a bit minimal. To learn more then the presentations and recording from several conferences are linked from the Project Jigsaw page and may be useful to you. In addition, there are a number of books on the topic. In particular, "Java 9 Modularity", by Sander Mak and Paul Bakker, is an excellent resource that will stand the test of time. That book has a section entitled "Resource Encapsulation" that should help you get going.

I assume by "clickable jar" you mean executable JARs, as in `java -jar app.jar`. There is no support at this time for starting modular applications with the `java -jar`.


Reply via email to