Modular Applications With Multi-Release JAR Files

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 batch file or script file provided below into the application installer or ship the file with the protected applications.

For more information, see Modifying Execution Files for Applications That Use JPMS.

Batch File to Integrate for Windows

java -version > %temp%\jenvelopetemp.txt 2>&1

for /F "tokens=3 delims= " %%a in ('findstr /I "version" %temp%\jenvelopetemp.txt') do set "uniuser=%%~a"

set /a uniuser=%uniuser

if %uniuser% geq 9 (
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>
) else (
java -jar <app_name>
)

del %temp%\jenvelopetemp.txt

SH File to Integrate for Linux

#!/bin/bash

JAVA_VER=`java -version 2>&1 | grep version | awk -F'"' '{print $2}' | awk -F'.' '{print $1}'`

if [ $JAVA_VER -ge 9 ];then
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>
else
java -jar <app_name>
fi

exit 0

Related Topics

Modifying Execution Files for Applications That Use JPMS

Java Prerequisites and Considerations

Protection Details

Defining Windows Program Protection Details

Working with Programs