Modifying Execution Files for Applications That Use JPMS
Sentinel LDK Envelope under Windows supports the protection of Oracle JDK 11 applications for Windows, Linux, and Mac. This includes applications that use the Java Platform Module System (JPMS).
As part of the protection process, Envelope generates files that contain the command required to execute module-based applications on the various platforms. These files are generated for JPMS applications that have Module-info.class and/or "Automatic-Module-Name" in their manifest file. You must modify the generated files to execute the protected application.
NOTE If there is a requirement to use a traditional JAR with a modular application, Thales recommends that you add the Automatic-Module-Name entry to the main manifest of the JAR file before you protect the application.
You must provide the Jar files as input in for protection in Envelope. As a result, Envelope generates the following batch and script files as part of the protection process:
>arg-runtime.bat contains additional flags to be used for Windows.
>arg-runtime.sh contains additional flags for to be used for Linux and Mac.
To support JPMS, only one batch file and one script file are generated, even for multiple jar files having same output file directory. The modules are located in the Modules directory under the Class Path.
The typical original command for executing the module-based application is similar to the following:
java --module-path <Module_dir> --module <module_name>/<package_name>.<class_name>.<main_method>
The module value appears above in bold text.
Open the generated batch or script file and append the module value from the original command.
The generated batch or script file contains the following text:
java --module-path <Module path> --class-path <Java_Envelope_Generated_Jars>; --add-reads <Module_name>=ALL-UNNAMED --add-exports <Module_name>/<package_name>=ALL-UNNAMED
After you append the module value, the batch or script file should appear as follows:
java --module-path <Module path> --class-path <Java_Envelope_Generated_Jars>; --add-reads <Module_name>=ALL-UNNAMED --add-exports <Module_name>/<package_name>=ALL-UNNAMED --module <module_name>/<package_name>.<class_name>.<Main_method>
where:
>The highlighted module value is copied from the original module-based application information
>--add-reads=ALL-UNNAMED
option provides read permission to unnamed code.
>--add-exports=ALL_UNNAMED
option provides export permission to unnamed code.
NOTE If all of the following conditions are true for a multi-release JAR file:
>The multi-release JAR file is targeted to be executed with both:
•Java 8 and earlier, AND
• Java 9 and later
>The java code targeted for Java 9 and later is for both JPMS-based and conventional applications.
You must integrate the provided batch file or script file into the application installer or ship the file with the protected applications.
Related Topics
Modular Applications With Multi-Release JAR Files
Java Prerequisites and Considerations