suggested document enhancement

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

suggested document enhancement

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.
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

Reply | Threaded
Open this post in threaded view
|

Re: suggested document enhancement

Alan Bateman
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`.

-Alan
Reply | Threaded
Open this post in threaded view
|

modules and resources [ was: suggested document enhancement]

Bernard Amade
thanks for replying

> Le 2 mars 2018 à 11:59, Alan Bateman <[hidden email]> a écrit :
>>
> 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
Reply | Threaded
Open this post in threaded view
|

Re: modules and resources [ was: suggested document enhancement]

Jochen Theodorou


Am 02.03.2018 um 15:14 schrieb 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

> 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

Reply | Threaded
Open this post in threaded view
|

Re: modules and resources [ was: suggested document enhancement]

Bernard Amade
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

> Le 2 mars 2018 à 15:43, Jochen Theodorou <[hidden email]> a écrit :
>
>
>
> Am 02.03.2018 um 15:14 schrieb 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
>
>> 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
>