自己的一次打包操作,按照自己的环境修改即可。
- 生成可以执行的jar (jdk17Demo.jar )
- 精简jre
D:\Language\Java\jdk17\bin\jdeps.exe jdk17Demo.jar
D:\Project\Java\jdk17Demo\out\artifacts\jdk17Demo_jar>D:\Language\Java\jdk17\bin\jdeps.exe jdk17Demo.jar
jdk17Demo.jar -> java.base
jdk17Demo.jar -> java.desktop
cn.com.gatico -> java.io java.base
cn.com.gatico -> java.lang java.base
cn.com.gatico -> java.lang.invoke java.base
cn.com.gatico -> java.lang.runtime java.base
cn.com.gatico -> java.util java.base
cn.com.gatico -> java.util.function java.base
cn.com.gatico -> java.util.random java.base
cn.com.gatico -> java.util.stream java.base
cn.com.gatico.from -> java.awt java.desktop
cn.com.gatico.from -> java.lang java.base
cn.com.gatico.from -> javax.swing java.desktop
- 导出精简的jre,保存至minimal-with-logging
D:\Language\Java\jdk17\bin\jlink.exe --output …/minimal-with-logging --add-modules java.base,java.desktop
D:\Project\Java\jdk17Demo\out\artifacts\jdk17Demo_jar>D:\Language\Java\jdk17\bin\jlink.exe --output ../minimal-with-logging --add-modules java.base,java.desktop
- 打包exe安装文件
D:\Language\Java\jdk17\bin\jpackage.exe
–win-dir-chooser
–win-menu
–win-shortcut
–win-menu-group gatico
–input D:\Project\Java\jdk17Demo\out\artifacts\jdk17Demo_jar
–name Test1
–main-class cn.com.gatico.from.Application
–main-jar jdk17Demo.jar
–runtime-image D:\Project\Java\jdk17Demo\out\artifacts\minimal-with-logging
–icon “C:\Users\7x-networks\Pictures\Saved Pictures\a.ico”
–app-version 1.0.0
–vendor gaticovendor
–copyright gaticocopyright
–description gaticodescription
–dest D:\Project\Java\jdk17Demo\out\exe - 生成之后的文件
- 双击安装,安装好的文件目录