The Java libraries ridl, unoil, juh, and jurt all export the package 'com.sun.star'.
This makes them incompatible with the Java 9 module system.
Steps to Reproduce:
1. Add at least two libraries to the module path.
Compilation fails with
error: the unnamed module reads package com.sun.star.security from both unoil and ridl
error: the unnamed module reads package com.sun.star.task from both unoil and ridl
error: the unnamed module reads package com.sun.star.util from both unoil and ridl
error: the unnamed module reads package com.sun.star.script from both unoil and ridl
error: the unnamed module reads package com.sun.star.uno from both jurt and ridl
Compilation completes without errors.
User Profile Reset: No
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36
openjdk9 is superseded, can you retest it with the 10.0.1 version off openjdk10.
Thanks for your reply.
Tested again with
openjdk 10.0.1 2018-04-17
OpenJDK Runtime Environment (build 10.0.1+10)
OpenJDK 64-Bit Server VM (build 10.0.1+10, mixed mode)
The problem persists.
Pinged devs on IRC and response was cautiously positive, so I will set this to NEW
how does one reproduce this? clearly it doesn't happen during any of the numerous junit tests that run as part of the LO build.
the SDK's jars don't make any claim to be Java Modules, FWIW, and if it's necessary to rearrange the content to make that possible - and thereby break compatibility - then i don't foresee that happening soon.
I'm having the same issue, but it's because I've included JavaFX 11 in my project. JavaFX 11 uses the new Java Modular system that was released in Java version 9. This means that when the project is compiled, any non modular libraries (i.e. LibreOffice Java API) are put into the unnamed module, where each jar file is treated as a module. Since ridl, unoil, juh, and jurt are all separate jar files, they are each treated like their own separate module. This is usually fine, except each jar shares liked named packages (i.e. ridl and jurt both have a package called com.sun.star.lib.util), which in the Java Modular system are called split packages. Before the Modular system, this was allowed to work without a hitch, but it's a non-starter with Java 9 on and causes errors that stops the project from compiling.
I have an example project that creates a JavaFX window with a button in it that would create an the SWriter example doc when clicked, but I'm not sure how to share it with everyone? The project uses NetBeans 11.0, AdoptOpenJDK 11, and JavaFX 11. If I can't share the code, you may be able to setup the project yourself by merging the JavaFX 12 helloworld example and the SWriter example. HelloWorld is here: https://github.com/openjfx/samples. And the Swriter example is here: https://api.libreoffice.org/examples/examples.html#Java_examples.
I think that the best way to solve this issue and still be compatible with older Java versions (Java 8), is to put ridl, unoil, juh, and jurt into a single jar file for Java 9 projects and above, but still have the 4 separate jars for Java 8 projects and below. By doing this, the Modular system would treat the single jar file as a single module. The modular system would then not flag this module as having split packages and the project could compile correctly.
@Rick, so merge the jars yourself and try it out? They're just zip files, it's really easy to do.
(In reply to Noel Grandin from comment #6)
> @Rick, so merge the jars yourself and try it out? They're just zip files,
> it's really easy to do.
...though you need to take care to include a proper combined meta-inf/manifest.mf
Sorry that this took so long, but I was finally able to merge all the required jars into one jar, included it into the program, and the program finally compiled and worked! I believe this is the solution to this problem. Would a merged jar be possible in future updates of LibreOffice?