brianm/really-executable-jars-maven-plugin

How to make a executable file for windows

Opened this issue · 3 comments

Hi,
I cannot find how to make a executable file for windows (either CMD or Powershell).
Any idea of how to do that?

I don't know windows well enough to know. The mechanism used here should be portable, in that self extracting archives exist on windows.

Off the top of my head, could try making the jar into a batch file (.bat) which works just like the shell script approach here. The next would be to prepend a proper windows binary which does the launching.

Apparently it's possible to create a script that works both on Windows and *nix:

https://github.com/Raynes/lein-bin/pull/29/files#diff-752180eb8dc62c50aabe89619582363f65cb62ee49284c846d82ed7fe156cd1b

Haven't tested this myself, but looks promising.

Inspired by the project you shared @klausbrunner, I've had success with
this single script which is compatible with both unix and windows

:;exec java -jar "$0" "$@"

@echo off
java -jar "%~f0" %*
goto :eof

:; lines are not interpreted by the windows shell, and is valid no-op bash

I'm not sure if the shebang can be put back.
The uber .jar has to be renamed with .bat to work out of the box in a windows shell.