Answer the question
In order to leave comments, you need to log in
How to distribute java programs under Windows?
The time is coming and it's time to start giving the program to clients in the form of an executable exe file instead of a batch file with the line java MyCoolApp.
How to do it right?
Answer the question
In order to leave comments, you need to log in
A commonly used method is to download launch4j , set it against your jar file and get the executable. In fact, this is a self-extracting archive with a launcher and the original file inside, but this is not visible to the user.
A better way is to use jlink : Simple
project directory structure
src
└───com.example
│ module-info.java
│
└───com
└───example
App.java
package com.example;
public class App {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
javac -d build\mods\com.example src\com.example\module-info.java src\com.example\com\example\App.java
jar --create --file=build\libs\com.example.jar --main-class=com.example.App -C build\mods\com.example .
jlink --module-path build\mods --add-modules com.example --output build\app\example --launcher start=com.example/com.example.App --compress=2 --no-header-files --no-man-pages --strip-debug
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question