JAL-3315 getdown_1_8_6 patch file. Needs careful applying.
[jalview.git] / JAVA-11-README
1 Java 11 module replacements
2
3 As Java 11 no longer ships with Java EE libraries, which were standard in Java 8, and available (modularised, through the --add-modules CLI mechanism) in Java 9 and 10, third party replacement libraries for these libraries/modules have to be found.
4
5 Ideally, these jar files would be packaged as modules (i.e. would contains a module-info.class with the relevant provision and requirements information for that module package).  However, as at time of writing (end Nov 2018) the available packages are not fully mature.
6 There also seems to be no single place to look when trying to obtain modules jar files.
7
8 A couple of good places to start:
9 https://javaee.github.io/
10 (see Metro, Glassfish etc)
11
12 https://search.maven.org/
13 (search for e.g. a:javax.activation)
14
15 https://mvnrepository.com/
16 (if the other two fail!)
17
18 Unfortunately there seems to be multiple projects providing the same modules, with little indication of which is "best".
19 Here's an example of what to do with search.maven.org, looking for, say, the java.activation module
20
21 Firstly, remember this might be called javax.activation (in fact it is), so searching for
22
23 a:javax.activation
24
25 shows 3 possible candidates.
26
27 The "Updated" date gives a clue if a library might be up-to-date or still being maintained, and of the three listed, com.sun.activation version 1.2.0 was updated in Sep 2017, and is the only one updated in the last 5 years, so it looks like a good candidate.
28 Click on the arrow in the Download column which gives various download options.  Choose "jar" and this should download straight away.
29
30 If you have a peek inside the jar file:
31
32 $ jar -tvf ~/Downloads/javax.activation-1.2.0.jar
33
34      0 Wed Sep 06 16:13:08 BST 2017 META-INF/
35   1307 Wed Sep 06 16:13:06 BST 2017 META-INF/MANIFEST.MF
36      0 Wed Sep 06 14:23:50 BST 2017 javax/
37      0 Wed Sep 06 14:23:50 BST 2017 javax/activation/
38      0 Wed Sep 06 14:23:50 BST 2017 com/
39      0 Wed Sep 06 14:23:50 BST 2017 com/sun/
40      0 Wed Sep 06 14:23:50 BST 2017 com/sun/activation/
41 ...
42   2238 Wed Sep 06 14:23:50 BST 2017 com/sun/activation/registries/LineTokenizer.class
43  39394 Wed Sep 06 16:13:06 BST 2017 META-INF/LICENSE.txt
44    581 Wed Sep 06 16:13:06 BST 2017 META-INF/mimetypes.default
45    292 Wed Sep 06 16:13:06 BST 2017 META-INF/mailcap.default
46      0 Wed Sep 06 16:13:08 BST 2017 META-INF/maven/
47      0 Wed Sep 06 16:13:08 BST 2017 META-INF/maven/com.sun.activation/
48      0 Wed Sep 06 16:13:08 BST 2017 META-INF/maven/com.sun.activation/javax.activation/
49   6515 Fri Sep 01 16:13:04 BST 2017 META-INF/maven/com.sun.activation/javax.activation/pom.xml
50    119 Wed Sep 06 14:23:52 BST 2017 META-INF/maven/com.sun.activation/javax.activation/pom.properties
51
52
53 you can see that it doesn't have a module-info.class file, meaning it can only be used as an "automatic" module.  This will probably mean it can't be used with jlink when creating a JRE.
54 HAVE NO FEAR!
55 We can semi-manually (urgh!) create a module-info.class for this library and turn it into a module.  This really should be scripted. I might just do it.
56
57 So, assuming we downloaded that jar to ~/Downloads/javax.activation-1.2.0.jar, and JAVA_HOME is set to a java distribution, we can do:
58
59 mkdir tmp
60 cd tmp
61 jar -xvf ~/Downloads/javax.activation-1.2.0.jar
62 jdeps --generate-module-info . ~/Downloads/javax.activation-1.2.0.jar
63 # --generate-module-info creates the module-info.java file we are looking for! but for some reason insists on sticking it in a java.activation subdir (even though we ask for '.')
64 mv java.activation/module-info.java .
65 rmdir java.activation
66 javac -d . module-info.java
67 # we could clean up (rm) module-info.java, but I think it'll be more useful to keep a hold of it in the jar, it's not causing a problem or taking up space
68 cd ..
69 jar -cvf javax.activation-1.2.0-MODULE.jar -C ./tmp .
70 /bin/rm -rf ./tmp
71
72 and voila, you have a modulified version of the library in the jar file ./javax.activation-1.2.0-MODULE.jar.  This can be used with jlink.
73 [ timeout: I scripted this as utils/modulify.sh  Usage: modulify.sh /path/to/jarfile.jar  ... creates /path/to/jarfile-MODULE.jar ]
74
75 Once we have enough modulified jar files (note, we kind of keep downloading a new file or files until jalview starts without Exceptions, jdeps could probably provide a better way(!), and jaxws-rt provides quite a few of the needed jar files, hopefully in a coherent way).
76
77 A list of module dependencies can be found with (note module-path doesn't need jar files, just the dirs to look in, unlike class-path)
78
79 jdeps --class-path="lib/*:j11lib/*" --module-path="$JAVA_HOME/jmods:j11lib" --list-deps dist/jalview.jar libs/*.jar
80
81 will end with a list of modules required in the JRE, these need to be comma-separated-listed for jlink.  We /ought/ to be able to do this by using "--print-module-deps" like this
82
83 jdeps --class-path="lib/*:j11lib/*" --module-path="$JAVA_HOME/jmods:j11lib" --print-module-deps dist/jalview.jar libs/*.jar
84
85 but that ends with an Exception.  Perhaps should look into that...
86
87 Anyway, with the list of modules required (in the file "modules") you can do
88
89 jlink --module-path $JAVA_HOME/jmods:j11lib --compress=2 --add-modules `cat modules` --no-header-files --no-man-pages --bind-services --output j11jre/openjdk11_platform
90
91 To create a Java 11 JRE in j11jre/openjdk11_platform (or whatever you wish to call it).
92 You can point JAVA_HOME at the JDK11 of a different platform, so long as the jlink in your path is to the jlink for the platform you're running on.
93
94