Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java 9 third party modules works with IDE but not with jlink

The program based on JDK 9(JPMS), using some third party jars like Apache (poi-3.17.jar, commons-io-2.6.jar ) & HikariCP (HikariCP-3.1.0.jar) , when using the IDE(Intellij) I "requires" them and the program works fine . When I try get my customeized JRE using java9 'jlink' I get the following :

/out$ jlink --module-path production --add-modules  
studyModule,java.base,java.datatransfer,java.desktop,java.logging,
java.scripting,java.sql,java.xml,java.prefs,javafx.base,
javafx.controls,javafx.fxml,javafx.graphics,javafx.media,
javafx.swing,javafx.web,jdk.jsobject,jdk.xml.dom,jdk.unsupported 
--output studyJre
Error: module-info.class not found for com.zaxxer.hikari module

/out$ jlink --module-path production --add-modules   
studyModule,java.base,java.datatransfer,java.desktop,java.logging,   
java.scripting,java.sql,java.xml,java.prefs,javafx.base,
javafx.controls,javafx.fxml,javafx.graphics,javafx.media,
javafx.swing,javafx.web,jdk.jsobject,jdk.xml.dom,jdk.unsupported 
--output studyJre
Error: module-info.class not found for poi module

questions is : why those packages with the IDE works fine ? if they not been moduleized then should not work in the IDE as well .

P.S : I added those jars to the "root" folder when working with jlink.

like image 483
Mohd Avatar asked Oct 17 '22 20:10

Mohd


1 Answers

Remember that jlink is a non-standard tool and it does not have to follow exactly the same rules as classic Java. One of its differences is that it requires all modules to be explicit (i.e. have module-info.class). Automatic modules are not supported. If you want to make a custom runtime image, you have to convert all automatic modules to explicit ones. See, for example, this question to know how to achieve it.

like image 130
ZhekaKozlov Avatar answered Nov 15 '22 03:11

ZhekaKozlov