1

I have a project written in Java 12 (fairly new to java9+ and using modules) and I want to use jlink to create a custom runtime image. I also want to use apache.commons.cli as a 3rd party library for my project. How can I make use of automatic modules and compile in order to create a jlink image?

I am getting errors like so:

tmp\commons.cli\module-info.java:3: error: package is empty or does not exist: org.apache.commons.cli exports org.apache.commons.cli; ^ 1 error

My structure is as follows:

C:. ├───.settings ├───bin │ └───com │ └───ngdesk ├───src │ ├───com │ │ └───ngdesk │ └───out └───target ├───classes │ ├───com │ │ └───ngdesk │ ├───META-INF │ │ └───maven │ │ └───ngDesk-ControlApp │ │ └───ngDesk-ControlApp │ └───out └───test-classes

Naman
  • 27,789
  • 26
  • 218
  • 353
npabs18
  • 167
  • 2
  • 10
  • Possible duplicate of [Is there a way to add maven dependencies while using the maven-jlink-plugin?](https://stackoverflow.com/questions/47103221/is-there-a-way-to-add-maven-dependencies-while-using-the-maven-jlink-plugin) – Naman Aug 01 '19 at 17:31
  • Do take a look at https://stackoverflow.com/questions/48408454/java-9-generating-a-runtime-image-with-jlink-using-3rd-party-jars and https://stackoverflow.com/questions/47222226/how-to-inject-module-declaration-into-jar if you are willing to update the legacy jar. – Naman Aug 01 '19 at 17:33
  • I am still getting the error 'package is empty or does not exist: ' even though i see the package in the jar – npabs18 Aug 02 '19 at 14:04
  • According to the error message, the problem occurs when `tmp\commons.cli\module-info.java` is compiled, hence, it is entirely unrelated to your project and the presence of `module-info.java` indicates that `commons.cli` is not an automatic module. So you’re failing at compiling the modular `commons.cli` and anything else you’ve posted, is irrelevant. – Holger Aug 07 '19 at 16:26

0 Answers0