Essay97
Essay97

Reputation: 874

How to bundle an executable jar file to be run as a cli command on macOS with jpackage (or similar tools)?

I have written a command line tool using picocli and Kotlin. Then I compiled it to an executable uber jar and it actually works as a standalone application by running

java -jar MyJarFile.jar [cli options and parameters]

But how do I bundle it so that I can distribute it on Mac, so that I can run it as

mycommand [cli options and parameters]

I know I can use jpackage, I used it and generated a .pkg file that installed the app on my Mac in the /Applications folder. I guess there is a file that i have to put in a folder that is in the PATH in order to use it as a command line tool. How do I "automate" the process? Is jpackage the right tool?

Wrapping up, what I want to do is to bundle my executable jar so that when the installation process on Mac finishes the user can write

mycommand [cli options and parameters]

Upvotes: 1

Views: 841

Answers (1)

Remko Popma
Remko Popma

Reputation: 36834

The picocli documentation has a list of options for packaging your application. (Suggestions for additional options are welcome.)

One of these options that deserves a special mention is creating a native image with GraalVM.

Upvotes: 0

Related Questions