Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to make a executable file for windows #23

Open
sinux-l5d opened this issue Dec 9, 2022 · 4 comments
Open

How to make a executable file for windows #23

sinux-l5d opened this issue Dec 9, 2022 · 4 comments

Comments

@sinux-l5d
Copy link

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

@brianm
Copy link
Owner

brianm commented Jan 3, 2023

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.

@klausbrunner
Copy link
Contributor

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.

@cyrilou242
Copy link

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.

@bgdnrvsky
Copy link

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.

Hi @cyrilou242, could you please specify how exactly did you achieve this ? Trying it for myself but keep getting Error: Invalid or corrupt jarfile C:\Users\raevs\Code\tmod\exec.bat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants