Created
April 2, 2023 01:13
-
-
Save lxfly2000/21e5aa4deb752bcad60aa645174487d2 to your computer and use it in GitHub Desktop.
针对可执行JAR应用程序生成JRE目录
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal EnableDelayedExpansion | |
::注意编码应保存为ANSI | |
::此处设置JDK的存放路径 | |
set JAVA_HOME=D:\zulu11.43.55-ca-jdk11.0.9.1-win_x64 | |
if "%~1"=="" ( | |
echo 命令行:%~n0 ^<JAR文件^> | |
echo 生成的JRE目录会保存至JAR文件的相同位置。 | |
goto:eof | |
) | |
path %path%;%JAVA_HOME%\bin | |
set DEPS= | |
for /f %%i in ('jdeps --list-deps %1') do ( | |
if "!DEPS!"=="" ( | |
set DEPS=%%i | |
) else ( | |
set DEPS=!DEPS!,%%i | |
) | |
) | |
jlink --module-path "%JAVA_HOME%\jmods" --add-modules !DEPS! --output "%~dp1\jre" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment