Discussion:
suggested document enhancement
Bernard Amade
2018-03-02 09:22:18 UTC
Permalink
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?

the doc at http://openjdk.java.net/projects/jigsaw/quick-start is good but lacks this kind of detail.

Thanks for any hint
Alan Bateman
2018-03-02 10:59:14 UTC
Permalink
Post by Bernard Amade
Hello all
since my job is to write java tutorials I have to confess I am lost on some topics about the module system.
- 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`.

-Alan
Bernard Amade
2018-03-02 14:14:38 UTC
Permalink
thanks for replying
Resources aren't a first class concept in the module system so we of course recommend using services itself.
so you mean reconsider the resource handling as a spi (as it is done with ResourceBundle)
explaining things to students will get pretty complicated since it should be split between resources located in the module and resources from external modules
BTW: another option may be that the "deployment programmer" updates the modular jar ( some signature problems?) or invoke with "patch-module" but is this politically correct ?

ok but why is the "old" way deprecated ? ( "first class" concept?)
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.
ClassLoader.getResource still works with resources located in other modules? the API doc says ...
"this method will only find resources in packages of named modules when the package is opened <https://docs.oracle.com/javase/9/docs/api/java/lang/Module.html#isOpen-java.lang.String-> unconditionally" for instance if I have a package with no code but resources only then IntelliJ does not want me to describe it in the module-info ... is this a spec or an IDE quirk?
. 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.
ok bought the book right now (but it will be shipped only in a fortnight ;-( )
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`.
Hmm.

1) you should explicitly document that so poor guys like me will not spend hours trying to understand what is happening (java's man does not states that!)

2) then what is the simplest way to deploy jars if clicking on a jar does not work anymore with modules?
(scripts are platform dependent, so are Jlink images ,...and what happens with jars delivered through java webstart? should we consider that java webstart is going to be deprecated?)

thanks

- Bear
Jochen Theodorou
2018-03-02 14:43:15 UTC
Permalink
Am 02.03.2018 um 15:14 schrieb Bernard Amade:
[...]
Post by Bernard Amade
2) then what is the simplest way to deploy jars if clicking on a jar does not work anymore with modules?
(scripts are platform dependent, so are Jlink images ,...and what happens with jars delivered through java webstart? should we consider that java webstart is going to be deprecated?)
from
http://www.oracle.com/technetwork/java/javase/9-deprecated-features-3745636.html
Post by Bernard Amade
docs/release_notes
Java Deployment Technologies are deprecated and will be removed in a future release
Java Applet and WebStart functionality, including the Applet API, The Java plug-in, the Java Applet Viewer, JNLP and Java Web Start including the javaws tool are all deprecated in JDK 9 and will be removed in a future release
So they are deprecated in 9 according to this, I think 10 prints a
warning still.

bye Jochen
Bernard Amade
2018-03-03 09:49:05 UTC
Permalink
I suspected that webstart will be deprecated but ...
that raises interesting questions:
- why is the java 9 doc not up to date?
https://docs.oracle.com/javase/9/deploy/toc.html (explicitly describes webstart)
- what would be a (future?) technology to update deliveries? (needed!)

(and btw this: https://docs.oracle.com/javase/9/docs/specs/jar/jar.html <https://docs.oracle.com/javase/9/docs/specs/jar/jar.html> is not also up to date since it does not says anywhere that -jar option was not compatible with modular jars )

thanks
[...]
Post by Bernard Amade
2) then what is the simplest way to deploy jars if clicking on a jar does not work anymore with modules?
(scripts are platform dependent, so are Jlink images ,...and what happens with jars delivered through java webstart? should we consider that java webstart is going to be deprecated?)
from http://www.oracle.com/technetwork/java/javase/9-deprecated-features-3745636.html
Post by Bernard Amade
docs/release_notes
Java Deployment Technologies are deprecated and will be removed in a future release Java Applet and WebStart functionality, including the Applet API, The Java plug-in, the Java Applet Viewer, JNLP and Java Web Start including the javaws tool are all deprecated in JDK 9 and will be removed in a future release
So they are deprecated in 9 according to this, I think 10 prints a warning still.
bye Jochen
Continue reading on narkive:
Loading...